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

What is the scope of global variable in c?

560


Explain what does the function toupper() do?

638


What are the rules for the identifier?

677


What is #line?

615


What is the right type to use for boolean values in c? Is there a standard type?

568






What would happen to X in this expression: X += 15; (assuming the value of X is 5)

1308


How can I find the modification date of a file?

708


Write a program to swap two numbers without using third variable?

817


How are structure passing and returning implemented?

594


Why does not c have an exponentiation operator?

631


process by which one bit patten in to another by bit wise operation is? (a) masking, (b) pruning, (c) biting, (d) chopping,

1895


Difference between exit() and _exit() function?

659


Explain with the aid of an example why arrays of structures don’t provide an efficient representation when it comes to adding and deleting records internal to the array.

2658


i have a written test for microland please give me test pattern

2189


How can I read/write structures from/to data files?

554