C++ examples for Data Type:char array
What does this program do? loop through \0 terminated string
#include <iostream> using namespace std; int mystery2( const char * ); // prototype int main() //from www . j a v a 2 s . co m { char string1[ 80 ]; cout << "Enter a string: "; cin >> string1; cout << mystery2( string1 ) << endl; } int mystery2( const char *s ) { int x; for ( x = 0 ; *s != '\0'; ++s ) ++x; return x; }