vendredi 8 février 2019

for loop including pointer

I tried to output a string "Hello" using pointer. Here is the code

char s[] = "Hello";  
char * p;
for( p = s; p[0]; ++ p )     
    cout << * p;
return 0;

I don't understand why "p[0]" in the for loop can work.

Aucun commentaire:

Enregistrer un commentaire