没有从cout获得输出

Not getting output from cout

本文关键字:输出 cout      更新时间:2023-10-16

我有一个与链表有关的项目。到目前为止,我只想输出我所拥有的,这样我就可以看到我在做什么,看到我在哪里,但我甚至无法做到这一点。

#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;
struct node;
typedef node* nodePtr;
struct node {
    int x;
    int hour;
    int minute;
    string owner_name;
    string pet_name;
    node* next;
};
void CreateList(nodePtr first, ifstream& inFile);
void PrintList(nodePtr first);
int main()
{
    nodePtr first;
    ifstream inFile("vetAppts.txt");
    if (inFile.fail()) {
    cout << "can't open the input file" << endl;
    }
    else {
        cout << "input file is open" << endl;
    }
    return 0;
    cout << "dsadsa";
    CreateList(first, inFile);
    PrintList(first);
}
void CreateList(nodePtr first, ifstream& inFile) {
    nodePtr newApp;
    newApp = new node;
    first = NULL;
    while (!inFile.eof()) {
        inFile >> first->hour;
        inFile.get();
        inFile >> first->minute;
        getline(inFile, first->owner_name);
        getline(inFile, first->pet_name);
    }
        cout << first->hour << first->minute << first->owner_name << first->pet_name;
}

我唯一的输出是"输入文件已打开"。

。。。。。。

if (inFile.fail()) {
    cout << "can't open the input file" << endl;
}
else {
    cout << "input file is open" << endl;
}
//return 0;

注释此return 0;,这将使程序退出。