Go through the following code sinippet
char a[20];
a="Hello Orcale Test";
will this compile?
Answers were Sorted based on User's Feedback
Answer / jaisai
No...
Compile time error will occur says
"left operand must be l-value"
alternatively
char *a;
a="Hello Orcale Test";
will compile....
| Is This Answer Correct ? | 6 Yes | 0 No |
Compile time err wil occur;
We can use *a="Hello Orcale Test" or a[20]="Hello Orcale
Test";
It will lead the prg nice.
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / 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 |
Answer / vignesh1988i
the above variable 'a' is a character array , so i would not been wrong if it has been initilized on the same line.....
but they have done that in the next line , there lies the mistake... THIS PROGRAM WILL GIVE AN ERROR why because we cant copy the entire string in a single travel by using '='(assignment) operator unless it's an initilization directly/.....
thank u
| Is This Answer Correct ? | 0 Yes | 0 No |
Explain what is wrong in this statement?
Which of the following sorts is quickest when sorting the following set: 1 2 3 5 4 1) Quick Sort 2) Bubble Sort 3) Merge Sort
write a function that accepts an array A with n elements and array B with n-1 elements. Find the missing one in array B,with an optimized manner?
What is a Genralised LInked List?? Please give a detailed explation of it..
What is C++
20. main() { int i=5; printf("%d%d%d%d%d%d",i++,i--,++i,--i,i); } Answer:??????
How many levels of pointers have?
Consider a language that does not have arrays but does have stacks as a data type.and PUSH POP..are all defined .Show how a one dimensional array can be implemented by using two stacks.
How can I access memory located at a certain address?
write a program of palindrome(madam=madam) using pointer?
write a c program to calculate sum of digits till it reduces to a single digit using recursion
in programming languages a statement or part of a statement that specifies several different execution sequences a) constructs b) distructs c) executes d) none