By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,191 Members | 812 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,191 IT Pros & Developers. It's quick & easy.

getline() special...

P: 2
Hey,

first of all sorry for my bad english, but I'm from Germany ;)

I found something special in the getline() function, I don't understand.

If I use the getline function in case of an Excel-sheet or an image - to get the image-data - the getline function breakes after a NULL termination ( \0 )

fstream oFile_e;

oFile_e.open("BAB.xls",ios::in);

oFile_e.getline(chTest, 100,'\n');


BAB.xls containes the \0 from position 9 to 12

chTest is after the getline function only filled up to position 9 ( after the first \0 )

--> no problem with the ios::binary mode. With this mode it's possible to read the whole data.

But if I write out some chars in a file and some of them are \0, I can read the whole data WITHOUT the ios::binary mode.

Do you understand that phenomenon?
Feb 26 '07 #1
Share this Question
Share on Google+
2 Replies


100+
P: 1,646
Hi. What is the \0 character you are referring to in the excel file? Is it a blank cell, NULL or zero?
Feb 26 '07 #2

P: 2
\0 = NULL

in hex = 0x00
Feb 26 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.