没有得到cout的输出

时间:2016-03-29 03:28:56

标签: c++

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

#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;
}

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

1 个答案:

答案 0 :(得分:1)

...

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

...

评论此return 0;,这会让您退出计划。