please help me in understanding the output of the file read

Status
Not open for further replies.

syedshan

Advanced Member level 1
Joined
Feb 27, 2012
Messages
463
Helped
27
Reputation
54
Reaction score
26
Trophy points
1,308
Location
Jeonju, South Korea
Visit site
Activity points
5,134
Hi all,

first of all please check the program, then I will share the output and confusion

Code:
using namespace std;

int main() {

 short int *num_ptr;

 ifstream myReadFile;
 myReadFile.open("filea.txt");
 
 if (myReadFile.is_open()) {
 while (!myReadFile.eof()) {
	 cout << myReadFile <<endl;
 }
 
}
 
 myReadFile.close();
return 0;
}

Now the file veeeery simple(for testing only, actual file has actual data).

But the output is as below image. Note that it runs continously, even though I have the eof function there and I have to stop it by pressing ctrl+c
The file is attached, (It has only 00's in itView attachment filea.txt
What I


- - - Updated - - -

Oh by the way,

the quesiotion is why such output, what I actually want to do is to read the whole file at once, then break it into the integer-16 bit and then send it to my FPGA, device, the actual file has 16-bit integer values( here represented as 000s only)
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…