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



what will the following program do? void main() { ..

Answer / abhiraj

a = malloc....


this sentence will give the error Lvalue required..

Is This Answer Correct ?    11 Yes 0 No

Post New Answer

More C Interview Questions

what is the use of #pragma pack, wer it is used?

2 Answers   Wipro,


main() { int i=5; printf("%d",++i + i); } output is 10 ------------------------ main() { int i=5; printf("%d",i++ + i); }output is 12 why it is so? give appropiate reason....

2 Answers  


How to declare a variable?

0 Answers  


What is union and structure in c?

0 Answers  


Is c pass by value or reference?

0 Answers  






What is a C array and illustrate the how is it different from a list.

1 Answers   Amazon,


What is the difference between typedef and #define?

0 Answers  


What does 1f stand for?

0 Answers  


What is scanf_s in c?

0 Answers  


write a program for the normal snake games find in most of the mobiles.

0 Answers   Accenture, Wipro,


What are the different types of constants?

0 Answers  


write a program to find the given number is prime or not

2 Answers   Accenture, Vasutech,


Categories