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
What is a null pointer in c?
any "C" function by default returns an a) int value b) float value c) char value d) a & b
Write a program to reverse a given number in c?
.find the output of the following program? char*myfunc(char*ptr) { ptr +=3; return (ptr); } int main() { char*x,*y; x="HELLO"; y=myfunc(x); printf("y = %s ",y); return 0; }
What is the auto keyword good for?
Write a program in "C" to calculate the root of a quadratic equation ax^2+bx+c=0, where the value of a,b & c are known.
When c language was developed?
Create a structure to specify data on students given below: Roll number, Name, Department, Course, Year of joining Assume that there are not more than 450 students in the college. 1.write a function to print names of all students who joined in a particular year 2.write a function to print the data of a student whose roll number is given
What is malloc() function?
What are the different types of constants?
Explain can you assign a different address to an array tag?
Explain why C language is procedural?
What is storage class?
Write a program to print fibonacci series without using recursion?
Is c is a procedural language?