What is the difference between char a[] = "string"; and
char *p = "string"; ?

Answer Posted / srinivas

a is a const pointer, whereas p is not
meaning 'a' will point to a fixed location (value of 'a' or
address of *a can't change, remains fixed) - though
contents of a can be changed (by way of accessing a[i])

Is This Answer Correct ?    36 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Differentiate fundamental data types and derived data types in C.

603


Write a code on reverse string and its complexity.

593


What is sizeof int in c?

591


Is linux written in c?

590


What are different types of variables in c?

559






What is use of #include in c?

585


i = 25;switch (i) {case 25: printf("The value is 25 ");case 30: printf("The value is 30 "); When the above statements are executed the output will be : a) The value is 25 b) The value is 30 c) The value is 25 The value is 30 d) none

634


general for is %wd,f-d; in this system "w" means a) 'w' represent total width of digits b) 'w' represent width which includes the digits before,after decimal place and the decimal point c) 'w' represent width which includes the digits before only d) 'w' represent width after decimal place only

576


What are multibyte characters?

637


Can a pointer be volatile in c?

524


What is meant by realloc()?

662


What is the purpose of type declarations?

666


Are pointers integers in c?

598


How do we print only part of a string in c?

577


A function can make the value of a variable available to another by a) declaring the variable as global variable b) Passing the variable as a parameter to the second function c) Either of the two methods in (A) and (B) d) binary stream

658