c++ writing individual characters from input to char array

closed account (Ey6Cko23)
I want to take a sentence or word and place the individual characters into an array of chars.
i want to do this in c++ but i don't know how to divide the input into individual chars.
std::string is basically a container for individual chars. You can access them with the element access operator "[]".

1
2
3
4
5
6
7
std::string String;
std::cin >> String;

for(unsigned i = 0; i < String.length(); ++i)
{
     std::cout << String[i] << "\n";
}


Last edited on
Topic archived. No new replies allowed.