Archived

This topic is now archived and is closed to further replies.

hello_there

length of a string

Recommended Posts

quote:
Original post by hello_there
but there might be other stuff on the line that i don't want to load.


Have you even read the documentation for that function ?
You obviously don't understand what it does.
Particularly what a 'line' is in this context.

If your string is null-terminated, getline, with a terminator of '\0' will read it. If not, you have to figure out where you want the string to end by yourself : space, tab, newline, comma, whatever.

The computer cannot "guess" when to stop reading if you don't tell it the length (surprise, surprise), or a character that marks the end.


[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]


[edited by - Fruny on October 6, 2003 1:35:09 AM]

Share this post


Link to post
Share on other sites
quote:
Original post by hello_there
Is a char always 1 byte on any computer?


Yes.

By the way, C++ defines 'byte' as the size of one char, not the other way round.

It says nothing about the number of bits, though.


[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]


[edited by - Fruny on October 6, 2003 3:16:09 AM]

Share this post


Link to post
Share on other sites