i use matlab to get the data.....after that i write the data in text file.......and i already read the data in text file using c++?
data in my file have only :-
0
1
2
when i use code below :-
ifstream input("test.txt"); //put your program together with thsi file in the same folder.
if(input.is_open()){
while(!input.eof()){
string number;
int data;
getline(input,number); //read number
data = atoi(number.c_str()); //convert to integer
cout<<data<<endl; //print it out
}
eof() only becomes true after you have already tried and failed to read from the file (which would cause a 0 to be output). Loop on the status of the stream instead.