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

An application package has been provided to you without any documents for the following application. The application needs to be tested. How will you proceed?

673


Can the “if” function be used in comparing strings?

597


how to find binary of number?

3439


What is floating point constants?

693


main() { inta=10,b=20; a>=5?b=100:b=200; printf("%d ",b); }

913






What is exit() function?

561


Write a Program to find whether the given number or string is palindrome.

613


Explain union.

638


Why do we use return in c?

569


How can I trap or ignore keyboard interrupts like control-c?

620


What are dangling pointers? How are dangling pointers different from memory leaks?

623


How is a null pointer different from a dangling pointer?

557


What are predefined functions in c?

568


Explain what are global variables and explain how do you declare them?

643


What are compound statements?

629