SIMPLE file io

i have a problem with reading a file and storing it in a dynamically allocated char array:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
	myfile.seekg(0,ios::beg);
	while(!(myfile.eof()))
	{
		
		myfile.get(b);
		MSIZE++;
		
	}
	myfile.setstate(ios::goodbit);
	myfile.seekg(0);
	int mt = myfile.tellg(); // i look at this to see what position in the file it's at, it stays at eof
	
	

	if(output==NULL)
	{
		output=new char[MSIZE+1];													//MSIZE
	}
	while(!(myfile.eof()))
	{
		
		myfile.get(b);
//		//MSIZE++;
		output[a]=b;
		a++;
	}


when i loop till not eof the second time it hasn't changed the position from .eof , any reasons for this?

also my char array isn't initialized to 0 either . . .
Last edited on
show me your entire source.
I don't know b, MSIZE, etc....

So I can't help you.
Topic archived. No new replies allowed.