Pointers
Pointers
Programming Fundamentals
int a; *b;
a=5;
b=&a;
int n= *b;
OR
n=*&a;
OR
n=a; //all three are same
200 208
ptr2 ptr2 ptr2 ptr2 ptr2 ptr2 ptr2 ptr2
char *str = “good”; //not a string copy, because the variable str is a
pointer, not a string
We can print the content of the string str using either printf or puts:
printf(“%s”, str);
puts (str);
Programming Fundamentals By Priya Singh (Assistant Professor, DTU)
ARRAY OF POINTERS
• Consider declaration of an array of strings.
Way-1: char name [3][25];
Way-2: char *name[3] = { “New Zealand”, Australia”, “India” };
//Here, name is an array having three elements where every element is a
pointer to character.