Ok, I have a saved file with the following information saved in binary format.
Mdog*Mcat*
My goal is to be able to read the file 1 char at a time,and when it reaches the '*' it puts a cout<<"\n"; in to make a new line. However, I am having trouble dealing with the primary code.
When I try to read the file, it comes out like this.
M2222
d2222
o2222
g2222
*2222
(I have it set to display 1 char at a time, then show the whole thing)
after, it displays...
*2222 (only the last char is read.
one thing to note is that to just get the basics running, the program will only read the first 5 characters.
I could use some help getting this thing to work.
Code:clrscr(); char ch ='\0'; int length; char * buffer; char * character; //Users *newrec; int endloop=0; ifstream readfile; readfile.open("Profiles.dat",ios::in |ios::binary); readfile.seekg (0, ios::end); length = readfile.tellg(); readfile.seekg (0, ios::beg); int k=0; character =new char[length]; int b=0; do { buffer[b] = new char; readfile.read (buffer,1); cout <<buffer <<k <<endl; k++; readfile.seekg (0,ios::cur); character[b]=buffer[b]; b++; cout <<character[b]<<endl; getch(); }while(k!=5); readfile.close(); cout << "Load succesful"; clrscr(); //cout <<character[length] <<endl; cout.write (buffer,k); getch();



LinkBack URL
About LinkBacks


