Click here to Skip to main content
14,884,042 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have two problem in my app.
fstream file;;
file.seekp(0, ios::end);
int length = file.tellp();
char* buffer=new char[length]; ,length);
CString DataStr(buffer);

1- when reading file I have some extra that char I didn't know where they come from?(I think I have mistake in read file's size)

2- after reading data I want to change it to CString but when I TRACE(SCtring) it send me "_CrtDbgReport: String too long or IO Error"?


You need to add an extra byte to the end of the buffer for the termination character and then add it to the end of the string thus:
char* buffer=new char[length + 1]; ,length);
buffer[length] = '\0';
tnx But!

end off my file is "d=7" TRACE show

and second question was not fix?
Richard MacCutchan 31-Jul-10 7:01am
Do what I suggested and try again.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900