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

Answer Posted / mak

in case of array size of it become fixed after initialization,
so a string of length greater than the size of previous string can't be assigned to array.
on the other hand pointer can take variable size string as it stores only the first address.

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is const volatile variable in c?

571


Write an efficient algo and C code to shuffle a pack of cards.. this one was a feedback process until we came up with one with no extra storage.

653


What are different types of pointers?

558


What are data structures in c and how to use them?

665


What are pointers in C? Give an example where to illustrate their significance.

745






hai iam working in sap sd module for one year and working in lumax ind ltd in desp department but my problem is i have done m.b.a in hr/marketing and working sap sd there is any combination it. can you give right solution of my problem. and what can i do?

1654


What happens if header file is included twice?

649


Whats s or c mean?

589


Write a function which takes as parameters one regular expression(only ? and * are the special characters) and a string and returns whether the string matched the regular expression.

643


Does c have class?

608


Why is sprintf unsafe?

613


What is the advantage of an array over individual variables?

728


Explain the meaning of keyword 'extern' in a function declaration.

712


What is wrong with this code?

688


Here is a neat trick for checking whether two strings are equal

558