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

Answer Posted / karuna

a[] is a constant pointer to a string;

char *p is a pointer to a constant string;

In a[] address of a[] cant be change but string can be
change.

In char *p address can be change string cant be change

Is This Answer Correct ?    15 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Where are c variables stored in memory?

826


Can we replace the struct function in tree syntax with a union?

1030


Difference between linking and loading?

911


Should a function contain a return statement if it does not return a value?

841


What are the advantages of using new operator as compared to the function malloc ()?

1082


What is variables in c?

830


What is indirection?

852


Explain what standard functions are available to manipulate strings?

839


Why do we use null pointer?

806


What does the file stdio.h contain?

828


I have written a pro*C program to fetch data from the cursor. where in i have used the concept of BULK FETCH.... each FETCH statement is taking lots of time to fetch specified number of rows at...

9949


Wt are the Buses in C Language

2982


Write a programme using structure that create a record of students. The user allow to add a record and delete a record and also show the records in ascending order.

1875


What are preprocessor directives in c?

858


a linearly ordered set of data elements that have the same structure and whose order is preserved in storage by using sequential allocation a) circular b) ordinary c) array d) linear list

854