C++ examples for Data Type:char array
Counts the number of letters in the user's first name, while Loop until null zero is reached.
#include <iostream> using namespace std; int main()/* w w w . java 2 s .c o m*/ { char name[15]; int count=0; // Get the user's first name cout << "What is your first name? "; cin >> name; while (name[count]) { count++; } cout << "Your name has " << count << " characters"; return 0; }