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 ctrl c called?
Can you write a programmer for FACTORIAL using recursion?
#include
What is pointer and structure in c?
Tell me when would you use a pointer to a function?
What is the difference between specifying a constant variable like with constant keyword and #define it? i.e what is the difference between CONSTANT FLOAT A=1.25 and #define A 1.25
Explain how do you override a defined macro?
Explain what is a program flowchart and explain how does it help in writing a program?
What is an example of structure?
Is stack a keyword in c?
Difference between macros and inline functions? Can a function be forced as inline?
program to find out date after adding 31 days to a date in the month of febraury also consider the leap year
Explain union.
How many bytes are occupied by near, far and huge pointers (dos)?
i want to know the procedure of qualcomm for getting a job through offcampus