Code for String handling by pointers in C Programming
main()
{
char *name;
int length;
char *cptr = name;
name = "DELHI";
printf (“%s\n”, name);
while(*cptr != '\0')
{
printf("%c is stored at address %u\n", *cptr, cptr);
cptr++;
}
length = cptr - name;
printf("\nLength of the string = %d\n", length);
}
Output
DELHI
D is stored at address 54
E is stored at address 55
L is stored at address 56
H is stored at address 57
I is stored at address 58
Length of the string = 5