簡體   English   中英

無法從cout獲取輸出

[英]Not getting output from cout

我有一個與鏈表有關的項目。 截至目前,我只想輸出自己擁有的東西,這樣我就可以看到自己在做什么,看到自己在哪里,甚至無法做到這一點。

#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; ,這使您可以退出程序。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM