cin and spaces

Discussion in 'C++' started by Samuele Armondi, Jun 23, 2003.

  1. 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
     
    Samuele Armondi, Jun 23, 2003
    #1
    1. Advertisements

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

    V
     
    Victor Bazarov, Jun 23, 2003
    #2
    1. Advertisements

  3. Thank you!
     
    Samuele Armondi, Jun 23, 2003
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.