473,320 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

getline() special

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 27 '07 #1
1 1516
ha****@atax-online.de wrote:
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?
I think this is covered in the FAQ 5.8.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Feb 27 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jim Phelps | last post by:
Hello all, I am in a bit of a pickle using the getline function with an ifstream. It does not seem to work as advertised. Here is my scenario. In a nutshell, my code needs to pick up a fixed...
1
by: ma740988 | last post by:
Consider: ifstrem MyFile("extractMe.txt"); string Str; getline(MyFile, Str); getline above extracts the contents of MyFile and place into the string object. Deduced using FROM/TO logic I...
10
by: Skywise | last post by:
I keep getting the following error upon compiling: c:\c++ files\programs\stellardebug\unitcode.h(677) : error C2664: 'class istream &__thiscall istream::getline(char *,int,char)' : cannot convert...
4
by: sam | last post by:
Hi, How can I use getline ignore the commandline arguments? Thanks Sam
18
by: Amadeus W. M. | last post by:
I'm trying to read a whole file as a single string, using the getline() function, as in the example below. I can't tell what I'm doing wrong. Tried g++ 3.2, 3.4 and 4.0. Thanks! #include...
5
by: allspamgoeshere3 | last post by:
Hi! I'm having trouble reading text lines from a file describing the levels for a simple game I'm creating. Inside the function that reads the content of the file there is a loop that basically...
2
by: FightingWolf | last post by:
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...
4
by: IanWright | last post by:
I'm having trouble with getline function, in the sense that I keep getting an error, and I'm wondering if anyone can help? The code I'm using is below. What it does is to read a line from one...
10
by: Terry IT | last post by:
hi, i'm using code like this string s while(getline(cin,s)){ process(s); } // this is the last line process(s);
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.