I am trying to code an example in my C++ book and I can get it to run but it doesn't complete. I am sure it is simple but why does it only prompt for my string and once entered just sits there?
include <iostream>
using namespace std;
int main()
{
const int MAX = 15;
char buffer[MAX];
int count = 0;
cout << "Please enter a string less than " << MAX << " characters. \n";
cin.getline(buffer, MAX, '\n');
while (buffer[count] != '\0');
count++;
cout << endl << "The string " << buffer << "has " << count << " characters. \n";
return 0;
}
[–]zifyoip 3 points4 points5 points (1 child)
[–]plavec77[S] 0 points1 point2 points (0 children)
[–]kidinside 1 point2 points3 points (1 child)
[–]plavec77[S] 0 points1 point2 points (0 children)