난 아직도 내 연결리스트를 추적 할 수 있지만, 일부 진전을 마련했는지 알아내는 데 문제가 있어요.링크 된 목록을 추적하고 있습니까?
내 코드는 완벽 노드를 통해 텍스트 파일에서 데이터를 읽고 있지만 모든 노드를 보여주기 위해 쇼 기능을 제대로을 전송하는 방법을 알아낼 수 없습니다. 노드에서 데이터보기 FILE (제대로 작동하지 않는)
void insertAsFirstElement(ifstream& budgetFile, budgetItem *&head, budgetItem *&last, int number, int& counter)
{
int ctype;
string cname;
double camount;
char clearOrNot;
while (!budgetFile.eof())
{
budgetItem *temp = new budgetItem;
budgetFile >> ctype >> cname >> camount >> clearOrNot;
temp->theType = ctype;
cout << temp->theType << endl;
//cout << ctype << endl;
temp->name = cname;
cout << temp->name << endl;
temp->amount = camount;
cout << temp->amount << endl;
if (clearOrNot == 'Y')
{
temp->cleared = true;
}
else
{
temp->cleared = false;
}
last = temp;
temp->next = NULL;
if (counter == 0)
{
//head = temp;
head = temp;
}
counter++;
}
}
FROM
READING (하나 개의 노드의 데이터가 표시되고 ...) * 나는 모든 노드 및 모든 데이터를 보여주는이 필요합니다. (해야 독서와 관련이 있음)
void showList(budgetItem *current)
{
if (isEmpty(current)) {
cout << "The list is empty." << endl;
}
else
{
cout << "The list contains: " << endl;
while (current != NULL)
{
cout << current->theType << " ";
cout << current->name << " ";
cout << current->amount << " ";
cout << current->cleared << endl;
current = current->next;
}
}
}
관련 내용 : 읽기 : [ "루프 상태에서 'iostream : eof'가 잘못된 것으로 간주되는 이유는 무엇입니까?]] (http://stackoverflow.com/questions/5605125/why-is-iostreameof-inside-a-loop -condition-considered-wrong) – WhozCraig
나는 그것을 읽었다. 팁을 주셔서 감사합니다 – Bubz21
하지만 지금까지의 문제에 대한 단서가 있습니까? – Bubz21