string input

C

coinjo

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

Ben Pope

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

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
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top