Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   New to C++ looking for help! (http://www.go4expert.com/forums/cpp-looking-help-t717/)

gloomfox 13Apr2006 07:18

New to C++ looking for help!
Hey I just started picking up c++ and was trying to write some of my own stuff. One problem I have come across is with the input. when im using standard cout/cin for strings, they work fine if i dont use a space while input'n, but as soon as I do it doesn't work.

I think I'm looking for streams but am unfamiliar with the correct code for it.
To use streams what do i need in the header? Does iostream work?
what are the uses I am looking for to enjoy input with spaces and other symbols for strings????

Thx a bunch ! :D

coderzone 13Apr2006 08:25

Re: New to C++ looking for help!
You need to be using cin.getline function for string containing spaces.

Here is the signature of of the getline function.
istream& getline (char* s, streamsize n, char delim );

A pointer to an array of characters.
The maximum number of characters to store, including the ternimating null character.
The delimiter. The operation of extracting succesive characters is stopped when delimiter is read. This parameter is optional, if not specified the function considers '\n' the delimiter.
Return Value.
The function returns *this

All times are GMT +5.5. The time now is 19:20.