string input

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • coinjo

    string input

    Can anyone please tell me how to take input from user of random length
    and then display it?

  • Ben Pope

    #2
    Re: string input

    coinjo wrote:[color=blue]
    > Can anyone please tell me how to take input from user of random length
    > and then display it?[/color]

    Random length?

    I presume that you mean they can use any number of characters, followed
    by some kind of terminating character.

    Take a look at
    std::string, std::getline, std::cin and std::cout

    from these headers:
    <iostream>
    <string>


    That allows the user to enter a line (a string terminated with a
    carriage return), read it into a string, and then display that string.

    This should be described in your favourite C++ reference.

    Ben Pope
    --
    I'm not just a number. To many, I'm known as a string...

    Comment

    Working...