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


Please Help Members By Posting Answers For Below Questions

Is it possible to use curly brackets ({}) to enclose single line code in c program?

801


What is the need of structure in c?

566


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.

1664


What is static identifier?

705


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(); }

1860






Can a pointer be volatile in c?

536


what is a constant pointer in C

681


How can I implement a delay, or time a users response, with sub-second resolution?

626


What is nested structure?

576


What are register variables? What are the advantage of using register variables?

688


What are the different types of linkage exist in c?

614


application areas a 'c' a) operating system b) graphics, interpreter, assembler c) program evalution, communication softwares d) all the above

609


Why c is called object oriented language?

592


Explain what is the difference between text files and binary files?

620


Which header file should you include if you are to develop a function which can accept variable number of arguments?

811