Strings can be referenced through pointers and traversed similar to arrays. - C String

C examples for String:char array

Description

Strings can be referenced through pointers and traversed similar to arrays.

Demo Code

#include <stdio.h> 
int main()//from   w ww  . j a  v a2s .c  om
{ 
   char *myString = "Mike"; 
   int x; 
   printf("\nThe pointer variable's value is: %p\n", *myString); 
   printf("\nThe pointer variable points to: %s\n", myString); 
   printf("\nThe memory locations for each character are: \n\n"); 

   //access & print each memory address in hexadecimal format 
   for ( x = 0; x < 5; x++ ) 
      printf("%p\n", myString[x]); 
}

Related Tutorials