#include <stdio.h>
#include <string.h>

int main()
{
int A;       // a number

int * ptrA;    // a term called ptrA capable of pointing to a number

ptrA = & A;     //   ptrA is set to point to A

A = 235;

// To print A

printf(" A = %d    \n", A );
printf(" A = %d    \n", * ptrA );  // contents pointed to by ptrA
printf(" A = %d    \n", * &A );   // contents of the address of A
// now with strings....

char name[10] = "charley";

char *N ;  // N is a pointer capable of pointing to name

N = &name[0] ;  // now N points to name ;

printf("\n the name is %s \n",  name );  // note that name represents the entire string  
printf(" the name is %s \n",  & *N );  // note that & *N represents the entire string  

return 0;
}

Return to previous page