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

Answer Posted / ashok

Pointers are fine a cannot be changed p can be changed.

I have a doubt like is there any difference in memory
allocation.

I heard like a gets its memory in local stack and p gets in
data section.

I don get the clear explanation

Is This Answer Correct ?    3 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain how do you print an address?

633


why use functions a) writing functions avoids rewriting the same code over and over b) using functions it becomes easier to write programs and keep track of what they are doing c) a & b d) none of the above

644


What is an example of structure?

575


Why #include is used in c language?

581


Did c have any year 2000 problems?

644






What is the return type of sizeof?

577


How can I list all of the predefined identifiers?

566


How main function is called in c?

615


If fflush wont work, what can I use to flush input?

594


What are the disadvantages of external storage class?

576


What is variable declaration and definition in c?

487


What is the use of a static variable in c?

578


Is c language still used?

526


What is typedf?

657


What is gets() function?

656