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

What is a null pointer in c?

584


any "C" function by default returns an a) int value b) float value c) char value d) a & b

656


Write a program to reverse a given number in c?

585


.find the output of the following program? char*myfunc(char*ptr) { ptr +=3; return (ptr); } int main() { char*x,*y; x="HELLO"; y=myfunc(x); printf("y = %s ",y); return 0; }

1979


What is the auto keyword good for?

612






Write a program in "C" to calculate the root of a quadratic equation ax^2+bx+c=0, where the value of a,b & c are known.

1714


When c language was developed?

626


Create a structure to specify data on students given below: Roll number, Name, Department, Course, Year of joining Assume that there are not more than 450 students in the college. 1.write a function to print names of all students who joined in a particular year 2.write a function to print the data of a student whose roll number is given

2500


What is malloc() function?

628


What are the different types of constants?

631


Explain can you assign a different address to an array tag?

632


Explain why C language is procedural?

760


What is storage class?

642


Write a program to print fibonacci series without using recursion?

594


Is c is a procedural language?

584