Reputation: 900
this issue is really strange to me.. I'm creating and writing into a simple file. When I'm reading with this code:
return_chars = new char[10];
file.read(return_chars, 10);
The result simply contains 4 characters more! It's 14 signs long. This happens only when reading 10 characters and some certain other numbers (24 for example). At a length of 8 it doesn't happen. The signs it adds are always the same at 10 characters: CE=0
This is the code I use for example to show what I read from the file:
MessageBoxA(NULL, return_chars, "title", 0);
Where is the issue? o.o Lots of thanks in advance!
Upvotes: 0
Views: 43
Reputation: 15919
Just a guess from the limited information you gave, maybe the showText method doesn't handle the return_chars array correctly because it isn't a null terminated string? You could try,
return_chars = new char[11];
file.read(return_chars, 10);
return_chars[10] = '\0';
showText(return_chars);
Upvotes: 3