the topic title pretty much sums it up how do i ask the user to write a name and put it inside a array as an string? might sound pretty easy but i really cant think of a way to do it. I can assign a string to an array when im writing the code but how do i input a string entered by a "user" in an array? i.e. while the program is running. help would be appreciated.
What you're looking for is the function "cin", found in <iostream>.
1 2 3 4 5 6 7 8
#include <string>
#include <iostream>
usingnamespace std;
string name;
cout << "Please enter a name: ";
cin >> name; // Waits for user input, then saves to "name".
cout << "Your name is " << name << "!";