istream::read question

closed account (4Gb4jE8b)
in the code shown here

1
2
3
4
5
6
7
8
9
10
11
12
13
Using namespace std
various declarations... including pause and fin

char* buffer;
int last;
fin.open(Parent_file.c_str());
last = ceil(end);
cout << last;
buffer = new char [last];
fin.read(buffer,end);
fin.close();
cout << buffer;
pause();


the output of the program through cout shows a large sum of what seem to be equal signs. When put into a file (which is done later in the code, not included), they give a very strange I with a ' or ` or some similar mark above it, instead of the data inside Parent_file.c_str(), which is a standard txt file from notepad (windows mind you).

Why does this happen, and how can i fix it and thus make it equal to the string of data in Parent_file?

please don't point me to the istream::read page. i've been there many a time, i need a little more personal help.

thanks for any help
I like that! You're hidding your pause function, that's smooth... That way the trolls can't call you on what they don't see.

If the "very strange 'I' " you describe was either ï, î, or ì then it's because the value that it read stretched into the extended ASCII table. How do you define the 'end' value used in lines 7 and 10?
Last edited on
the trolls


Hmm...Where has xorebxebx gone?
Haven't seen him around lately :D
closed account (4Gb4jE8b)
ha! i didn't even think of that, i've just come to the habit of doing that myself because of how often i call it in any of my projects.

the i was capitalized "Í" is the exact character. and it appears for all characters (yes i have multiple 4kb files with this as it's only character, it's quite displeasing to look at, like having everything you've worked on for the last two weeks rubbed in your face as 'not good enough' :P).

end is the size of the file in bytes, the reason i have that conversion there is because originally end was a float type so i could convert it to kilobytes.

EDIT: when i make buffer = a set of example text, these characters and such don't appear. It was probably obvious that this would happen but i dunno what you guys might need to answer my question :P
Last edited on
Topic archived. No new replies allowed.