Go through the following code sinippet
char a[20];
a="Hello Orcale Test";
will this compile?
Answer Posted / pradeep
Dear frd,
char a[20];
a="Hello Orcale Test";
Here you are trying to "assign" constant char string to
address variable , as you are aware that name of an array
points to the first address of the array element. So here
you wil get an error message saying L value is required.
and also
char *a;
*a="hello" ; also will give an error as you are trying to
assign constant characters to char type variable.
Type mismatch will occur.
so I suggest you to use the strcpy method to copy a
constant character string to char*
so soln is
char a[20];
strcpy(a,"hello world");
or char *a;
a="hello";
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
What is static and auto variables in c?
What is bss in c?
Define Spanning-Tree Protocol (STP)
which of the following shows the correct hierarchy of arithmetic operations in C a) (), **, * or/,+ or - b) (),**,*,/,+,- c) (),**,/,*,+,- d) (),/ or *,- or +
Write the program that calculates and prints the average of several integers. Assume that the last value read is sentinel 9999.
Is c a great language, or what?
Lists the benefits of c programming language?
Does c have an equivalent to pascals with statement?
write a proram to reverse the string using switch case?
Explain a pre-processor and its advantages.
How to implement a packet in C
What does static variable mean in c?
Can we access the array using a pointer in c language?
What is a null pointer assignment error? What are bus errors, memory faults, and core dumps?
What are the uses of null pointers?