Is the text file in the same directory as your program?
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
Can you try dumping your text file in the c: drive then change your program so this line:inStream.open("Sarawak_Cnx.txt");
becomes: inStream.open("C:\\Sarawak_Cnx.txt");
What happens now?
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
Um no using an array and indexing should be easier to understand than pointers and is perfectly ok. I'd stick with that.
Just to let you know the way you are reading in data from a file is wrong and horribly flawed. Shall I show you the correct way.
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
Oops sorrie I gotta go. :(
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
Yeah basically you wanna use something like
#include <iostream> //basic i/o
#include <fstream> //file input out
#include <string> //string handling
using namespace std;
int main()
{
//open a file for reading
ifstream read ("foo.txt");
string chunk; //this will be the string which holds each word or number
while ( read >> chunk )
{
cout << chunk << endl;
}
read.close(); //close file
return 0;
}
to read files, instead of eof as that has problems. As a newbie I don't think it is important to bore you with the details as to why eof is bad.
Obviously after that you need to convert the string to actual numbers. But I'm not sure if you are allowed to use strings. Let me know.
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439