Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   cin and spaces (http://www.velocityreviews.com/forums/t267616-cin-and-spaces.html)

Samuele Armondi 06-23-2003 05:28 PM

cin and spaces
 
Hi,
I'm trying to use cin to capture some input from the console, but it always
seems to consider a space as the end of the string. I tried to use
cin.getline() but it only works for char arrays, and I would rather use
strings. At the moment, I'm using getline to read the input into a char
array and I'm then making a string out of it. Is there a more elegant way of
doing this?
Thanks in advance,
S. Armondi

--
To contact me by email, remove _NOSPAM_ from the address.



Victor Bazarov 06-23-2003 05:30 PM

Re: cin and spaces
 
"Samuele Armondi" <sammyboyuk_NOSPAM_@hotmail.com> wrote...
> I'm trying to use cin to capture some input from the console, but it

always
> seems to consider a space as the end of the string. I tried to use
> cin.getline() but it only works for char arrays, and I would rather use
> strings. At the moment, I'm using getline to read the input into a char
> array and I'm then making a string out of it. Is there a more elegant way

of
> doing this?


std::getline(std::cin, somestring);

V



Samuele Armondi 06-23-2003 10:28 PM

Re: cin and spaces
 

"Victor Bazarov" <v.Abazarov@attAbi.com> wrote in message
news:vfee8mpvbi921f@corp.supernews.com...
> "Samuele Armondi" <sammyboyuk_NOSPAM_@hotmail.com> wrote...
> > I'm trying to use cin to capture some input from the console, but it

> always
> > seems to consider a space as the end of the string. I tried to use
> > cin.getline() but it only works for char arrays, and I would rather use
> > strings. At the moment, I'm using getline to read the input into a char
> > array and I'm then making a string out of it. Is there a more elegant

way
> of
> > doing this?

>
> std::getline(std::cin, somestring);
>
> V
>
>

Thank you!




All times are GMT. The time now is 01:26 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.