#include<iostream>
#include<vector>
#include<string>
int main()
{
std::vector<std::string> names;
for (int loop=0; loop!=10;)
{
std::cout << ++loop << " enter a name: ";
std::string name;
std::cin >> name;
names.push_back (name);
}
}
Chat with our AI personalities
This sounds like a homework question...
To prompt a user in C++ you use cout to output the prompt to the console (e.g., the screen). You then use cin to extract the input from the user. So to get user input without a prompt, simply do not output a prompt before accepting input. However, accepting user input without a prompt would be decidedly un-user-friendly, unless you can guarantee the input does not come from the keyboard. If you're not using the console and the program is actually running in an event-driven interface (such as Windows), then you need only trap the keyboard, mouse or other HID messages that are posted to your application via the application's message loop, and act accordingly.
For example, to interpret user input; to read data from a text file or from some other program that produces the data as a string.For example, to interpret user input; to read data from a text file or from some other program that produces the data as a string.For example, to interpret user input; to read data from a text file or from some other program that produces the data as a string.For example, to interpret user input; to read data from a text file or from some other program that produces the data as a string.
Interactive mode
An input stream is a character sequence device or buffer from which input can be gathered. The standard input stream is usually a keyboard, data file or the output stream from another program. The user of the program can normally decide where standard input may be redirected from when launching the program, typically defaulting to the keyboard.