what will the following program do?
void main()
{
int i;
char a[]="String";
char *p="New Sring";
char *Temp;
Temp=a;
a=malloc(strlen(p) + 1);
strcpy(a,p);
//Line no:9//
p = malloc(strlen(Temp) + 1);
strcpy(p,Temp);
printf("(%s, %s)",a,p);
free(p);
free(a);
}
//Line no 15//
a) Swap contents of p & a and print:(New string, string)
b) Generate compilation error in line number 8
c) Generate compilation error in line number 5
d) Generate compilation error in line number 7
e) Generate compilation error in line number 1
Answer Posted / abhiraj
a = malloc....
this sentence will give the error Lvalue required..
| Is This Answer Correct ? | 11 Yes | 0 No |
Post New Answer View All Answers
What is a scope resolution operator in c?
write a c program for swapping two strings using pointer
How can you pass an array to a function by value?
Explain how do you sort filenames in a directory?
Can you please explain the scope of static variables?
What is function definition in c?
Explain how are 16- and 32-bit numbers stored?
What would happen to X in this expression: X += 15; (assuming the value of X is 5)
Explain what is the use of a semicolon (;) at the end of every program statement?
What is the size of a union variable?
Why is c used in embedded systems?
Write a program to print ASCII code for a given digit.
how we can make 3d venturing graphics on outer interface
Can a pointer be volatile in c?
Which control loop is recommended if you have to execute set of statements for fixed number of times?