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
How can I change the size of the dynamically allocated array?
What should malloc() do?
int i=3; this declaration tells the C compiler to a) reserve space in memory to hold the integer value b) associate the name i with this memory location c) store the value 3 at this location d) all the above
What is a pointer and how it is initialized?
How can I open a file so that other programs can update it at the same time?
program to find error in linklist.(i.e find whether any node point wrongly to previous nodes instead of next node)
How will you divide two numbers in a MACRO?
When should a far pointer be used?
Take an MxN matrice from user and then sum upper diagonal in a variable and lower diagonal in a separate variables. Print the result
What is the use of pointers in C?
Explain function?
How can I find out how much free space is available on disk?
write a program to create a sparse matrix using dynamic memory allocation.
Why C language is a procedural language?
What is wrong with this declaration?