What is the difference between char a[] = "string"; and
char *p = "string"; ?

Answer Posted / karuna

a[] is a constant pointer to a string;

char *p is a pointer to a constant string;

In a[] address of a[] cant be change but string can be
change.

In char *p address can be change string cant be change

Is This Answer Correct ?    15 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can I read in an object file and jump to locations in it?

582


C program execution always begins with a) #include b) comment (/*-------*/) c) main() d) declaration instructions

613


a=10;b= 5;c=3;d=3; if(a printf(%d %d %d %d a,b,c,d) else printf("%d %d %d %d a,b,c,d);

646


What is meant by type casting?

629


Can a program have two main functions?

573






Write a program to print fibonacci series without using recursion?

611


Tell me what is the purpose of 'register' keyword in c language?

620


How can I trap or ignore keyboard interrupts like control-c?

620


How can variables be characterized?

1653


What are the uses of a pointer?

684


what are the different storage classes in c?

662


How do you define a string?

658


Explain About fork()?

649


What is c definition?

751


How are strings stored in c?

596