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
Is it possible to use curly brackets ({}) to enclose single line code in c program?
What is the need of structure in c?
1.int a=10; 2.int b=20; 3. //write here 4.b=30; Write code at line 3 so that when the value of b is changed variable a should automatically change with same value as b. 5.
What is static identifier?
find the output? void r(int a[],int c, int n) { if(c>n) { a[c]=a[c]+c; r(a,++c,n); r(a,++c,n); } } int main() { int i,a[5]={0}; r(a,0,5); for(i=0;i<5;i++) printf("\n %d",a[i]); getch(); }
Can a pointer be volatile in c?
what is a constant pointer in C
How can I implement a delay, or time a users response, with sub-second resolution?
What is nested structure?
What are register variables? What are the advantage of using register variables?
What are the different types of linkage exist in c?
application areas a 'c' a) operating system b) graphics, interpreter, assembler c) program evalution, communication softwares d) all the above
Why c is called object oriented language?
Explain what is the difference between text files and binary files?
Which header file should you include if you are to develop a function which can accept variable number of arguments?