What is the difference between char a[] = "string"; and
char *p = "string"; ?
Answers were Sorted based on User's Feedback
Answer / dharanidhar
P is a pointer which is constant. So, the values in this
array cannot be modified.
characters within a[] can be changed by accessing
like a[1] = '2',....
Is This Answer Correct ? | 1 Yes | 3 No |
Answer / parmjeet kumar
char a[] will alocate the momery size of " string" word in
other hand char *p will alocate the memory size of one
character... or we can not move the data from one location
to another location but with pointer we can do it...
Is This Answer Correct ? | 1 Yes | 5 No |
Answer / ashish
here a is an array and is a char const * data type.
hence u cannot change value of a but u can change the value
which a points to.
p on the other hand is a const char * data type.
hence value of p an be changed but the value p points to
cannot be changed.
i dont know the answer!!! :P
Is This Answer Correct ? | 3 Yes | 13 No |
Answer / 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 |
What is the use of a conditional inclusion statement in C?
Hi Every one...........I have been selected for the SBI Clerk. But i m one month Pregnanat. So anyone please suggest me, is they take any objection on my joining .
4 Answers State Bank Of India SBI,
What is array of structure in c programming?
write a program that reads lines(using getline), converts each line to an integer using atoi, and computes the average of all the numbers read. also compute the standard deviation.
Write a c program to demonstrate character and string constants?
My teacher ask to make a program that can: Insert record in front Insert record at the end Insert in between Search node record Delete record in front Delete record at the end Delete record in between Using Data structure Linked List type. But I'm really confused about the codes and I can't go through. Please help Thanks in advance. Also here is my unfinished code if someone can make changes it will be more good.
number 2 plssssss help !!....using array.. turbo c.. create a program that will accept a number and determine if it is a happy number or an unhappy number.. example: enter a number : 7 7*7=49 then 4 and 9 4*4 and 9*9== 16 + 18 gives you 97 then 9 and 7 9*9 and 7*7 == 81 + 49 gives you 130 then 1 and 3 1*1 and 3*3 == 1 + 9 gives you 10 1*1 gives you 1 sample output: 7= 49= 16+81= 97= 81+49=130 =1+9=10 =1 "7 is a happy number" . if the last number is 2 then the number being inputed is not a happy number.
4) Write a program that takes a 5 digit number and calculates 2 power that number and prints it.
What is the use of function overloading in C?
12. Look at the Code: main() { int a[]={1,2,3},i; for(i=0;i<3;i++) { printf("%d",*a); a++; } } Which Statement is/are True w.r.t the above code? I.Executes Successfully & Prints the contents of the array II.Gives the Error:Lvalue Required III.The address of the array should not be changed IV.None of the Above. A)Only I B)Only II C)II & III D)IV
main() { inta=10,b=20; a>=5?b=100:b=200; printf("%d ",b); }
Linked lists -- can you tell me how to check whether a linked list is circular?