What is the difference between char a[] = "string"; and
char *p = "string"; ?
Answer Posted / kurvatis
When a program starts its content copies from external
memory like a hard drive to a PROTECTED from writes part of
RAM. No any byte in that area can be changed!
Now the difference.
char * p = "this string is in protected memory and cannot be
changed";
You cannot change the string located in protected memory a
pointer points to.
char a[] = "this string is in memory that can be changed";
Theoretically char * p = "string"; eat less memory than
another one.
| Is This Answer Correct ? | 8 Yes | 3 No |
Post New Answer View All Answers
how to capitalise first letter of each word in a given string?
The performance of an operation in several steps with each step using the output of the preceding step a) recursion b) search c) call by value d) call by reference
What is the difference between null pointer and wild pointer?
Define and explain about ! Operator?
What is a scope resolution operator in c?
Why c language?
What are inbuilt functions in c?
What is difference between scanf and gets?
How many types of operator or there in c?
Are bit fields portable?
Explain what header files do I need in order to define the standard library functions I use?
How arrays can be passed to a user defined function
Explain what is the general form of a c program?
How can you allocate arrays or structures bigger than 64K?
Why main function is special give two reasons?