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
Here is a neat trick for checking whether two strings are equal
What does 1f stand for?
Define Spanning-Tree Protocol (STP)
write a program to generate address labels using structures?
Hai,I have done with my bachelor of commerce and planing to ms,please suggest me how to convince vo for shifting from commerce to computers. Visa on 8 DEC 2014 Npu university
What would the following code segment printint k = 8;docout << "k = " << k << " ";while k++ < 5; a) 13 b) 5 c) 8 d) pointers
What functions are used in dynamic memory allocation in c?
What do you mean by dynamic memory allocation in c? What functions are used?
Differentiate between a structure and a union.
main() { inta=10,b=20; a>=5?b=100:b=200; printf("%d ",b); }
Explain is it valid to address one element beyond the end of an array?
Find duplicates in a file containing 6 digit number (like uid) in O (n) time.
Why doesnt the call scanf work?
What is the difference between constant pointer and constant variable?
What are the string functions? List some string functions available in c.