this code compiles alright but it doesnt run right......i simply want to get characters from a file and then output them. anyone see why this doesnt work? i believe it has something to do with the eof marker but i could be wrong. anyways, heres the code.....
Code:#include <iostream> #include <fstream> #include <string> using namespace std; struct list { char data; list *link; list *beginning; list *current; list *pend; }; typedef list* listptr; void main() { string temp; char next; ifstream in_stream; cout << "Enter filename"; cin >> temp; in_stream.open(temp.c_str()); in_stream.get(next); listptr top; top = new list; top->data = next; top->link = NULL; in_stream.get(next); while(! in_stream.eof()) { listptr temp; temp = new list; temp->data = next; temp->link = top; top = temp; } while(top != NULL) { char result; result = top->data; listptr temp; temp = top; top = top->link; delete temp; cout << result << endl; } }