#include<stdio.h>
void main()
{
char *name;
int length;
char *cptr=name;
name="DELHI";
printf("%s\n",name);
while(*cptr!='\0')
{
printf("%c is stored at adress %u\n",*cptr,cptr);
cptr++;
}
}
#include<stdio.h>
void main()
{
char *name;
int length;
char *cptr=name;
name="DELHI";
printf("%s\n",name);
while(*cptr!='\0')
{
printf("%c is stored at adress %u\n",*cptr,cptr);
cptr++;
}
}
you have to initialize name at the time of creating string .
#include<stdio.h>
void main()
{
char name[ ]= "DELHI";
char *cptr=name;
printf("%s\n",name);
while(*cptr!='\0')
{
printf("%c is stored at adress %p\n",*cptr,cptr);
cptr++;
}
return 0;
}