/* * pointstr2.c */ #include int main(void) { char str[]="Having fun with pointers?"; char * pstr; // pstr points to address &str[0] pstr=str; /* print str by accessing each element of a for loop */ for( ; *pstr; pstr++ )// initilize nothing // when value at pstr == NULL, quit loop // do block // incremnt pointer address by 1 data size { printf("%c", *pstr); } printf("\n"); // print str and address by accessing each element in a for loop for(pstr=str; *pstr; pstr++) // initialize pointer to &str[0] // when value at pstr == NULL, quit loop // do block // // incremnt pointer address by 1 data size { printf("%c %p\n", *pstr, pstr);// print char at pstr, and it's address } printf("\n"); printf(" Now pstr points to %p, the NULL\n\n", pstr); return 0; }