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
How can I make it pause before closing the program output window?
What is the correct code to have following output in c using nested for loop?
How can I read in an object file and jump to locations in it?
What are the main characteristics of c language describe the structure of ac program?
what is the different bitween abap and abap-hr?
What does the message "automatic aggregate intialization is an ansi feature" mean?
What is else if ladder?
how to introdu5ce my self in serco
Why c is called a middle level language?
How can I handle floating-point exceptions gracefully?
How do we make a global variable accessible across files? Explain the extern keyword?
write an interactive C program that will encode or decode a line of text.To encode a line of text,proceed as follows. 1.convert each character,including blank spaces,to its ASCII equivalent. 2.Generate a positive random integer.add this integer to the ASCII equivalent of each character.The same random integer will be used for the entire line of text. 3.Suppose that N1 represents the lowest permissible value in the ASCII code,and N2 represents the highest permissible value.If the number obtained in step 2 above(i.e.,the original ASCII equivalent plus the random integer)exceeds N2,then subtract the largest possible multiple of N2 from this number,and add the remainder to N1.Hence the encoded number will always fall between N1 and N2,and will therefore always represent some ASCII character. 4.Dislay the characters that correspond to the encoded ASCII values. The procedure is reversed when decoding a line of text.Be certain,however,that the same random number is used in decodingas was used in encoding.
Explain enumerated types in c language?
Do array subscripts always start with zero?
Can the curly brackets { } be used to enclose a single line of code?