what do you mean "it failes"? it won't compile? it won't run? what error(s) do you get? Note: unless its just a posting error, it needs a semicolor at the end of the cout line. Also, how is buffer declared?
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
did you try this
char buffer[6];
for(int i = 0; i < 5; i++)
cin >> buffer[i];
buffer[5] = 0;
cout << buffer << endl;
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
By "user enters A" what exactly do you mean? one character? a whole string of characters? a number?
std::string buffer[5];
for(int i = 0; i < 5; i++)
{
cout << "Enter string #" << i+1;
getline(cin,buffer[i]);
}
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343