It would be nice if someone could help with this problem:
I run this with a file "numb.num" in my E:\ directory that contains:
Here's the program:
Code:
#include <iostream.h>
#include <fstream.h>
#include <windows.h>
#include <dos.h>
#include <conio.h>
#include <stdlib.h>
struct node {
int x;
node *next;
};
void main() {
ifstream file1("E:\numb.num");
int total, a[700], n;
node *root;
node *p;
root->next = NULL;
for (n = 0;file1.eof();n++) {
file1 >> a[n];
}
for (n = 0;file1.eof();n++) {
root->x = a[n];
root->next = new node;
}
root->next = NULL;
p = root;
for (n = 0;n == NULL || p->next == NULL;n++) {
total += p->x;
cout << p->x << " ";
p = p->next;
}
cout << endl << "The total is: " << total << endl;
p->next = NULL;
file1.close();
}
Windows crashes the program. And that's about it. I use Visual C++ 6.0 on Windows 98.