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

Answer Posted / aravind

hi im answering as far as i know , pls say ur feedback,,,(+_+)
Array:
for char array char a[]; no such array size is accepted by
the compiler. That is , it requires a fixed size for the
array like: char a[20];

in this case the number of strings / characters it can hold
is only upto 20 while if it exceeds , the input strings get
truncated. [STATIC MEMORY ALLOCATION AND TRAVERSAL WITHIN
BOUNDS]

Pointer:
Whereas in case of pointers it is of DYNAMIC MEMORY type and
infinite storage when compared to Array. and predefinition ,
truncation are absent.
Also TRAVERSAL is easy.

Is This Answer Correct ?    6 Yes 23 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How is null defined in c?

646


the 'sizeof' operator reported a larger size than the calculated size for a structure type. What could be the reason?

554


what is the differnce between programing langauge and tool? is sas is a programing langauge r tool?

1896


What is typedef?

658


how to build a exercise findig min number of e heap with list imlemented?

1601






Differentiate between static and dynamic modeling.

611


what do the 'c' and 'v' in argc and argv stand for?

638


how to make a scientific calculater ?

1554


How can a program be made to print the line number where an error occurs?

640


How are portions of a program disabled in demo versions?

741


Explain about block scope in c?

655


Where static variables are stored in c?

581


How can you check to see whether a symbol is defined?

583


how to construct a simulator keeping the logical boolean gates in c

1719


What is the difference between variable declaration and variable definition in c?

557