0
私はこのプロジェクトをリンクリストと関連させています。現時点では、私は自分が持っているものを出力したいので、私が働いているものを見ることができ、私がどこにいるかを見ることができ、私はそれをすることさえできません。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;
}
「入力ファイルは開いています」という唯一の出力があります。
"入力ファイルが開いている"行( 'return 0')の直後にプログラムが終了します。 – vesan
これは問題ではありませんが、余分なものが必要な場合を除き、 'std :: endl'を使用しないでください。 '' \ n ''は行を終わらせます。 –