#include <iostream>
#include <string>
usingnamespace std;
int main(){
char names[50] = "Jeff";
for( int i = 0 ; i < strlen(names) ; i ++ ){
cout << names[i];
}
cout << endl;
system( "pause" );
return 0;
}
In the code above , you can see that i using strlen
This is to determine the string sizeof it , because if you using char names[50] = "Jeff" .
You only using the [0] = J , [1] = e , [2] = f , [3] = f, so from [4] to [50] will be = "/0" , if you use looping , the space will be print out .