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 cohesion in c?

0 Answers  


What is the benefit of using const for declaring constants?

0 Answers  


. Consider the following program main() { int a[5]={1,3,6,7,0}; int *b; b=&a[2]; } The value of b[-1] is (A) 1 (B) 3 (C) -6 (D) none

9 Answers   Oracle,


what is the difference between normal variables and pointer variables..............

15 Answers   HP, Infosys, Satyam, Vivekanand Education Society,


State the difference between realloc and free.

0 Answers   Aricent,






write a program for fibonaci series by using while loop in c?

2 Answers  


How can I write a function that takes a format string and a variable number of arguments?

0 Answers  


what is the advantage of using SEMAPHORES to ORDINARY VARIABLES???

2 Answers   NSN,


How is null defined in c?

0 Answers  


What is hashing in c?

0 Answers  


to find the program of matrix multiplication using arrays

6 Answers   Bhel,


#define min((a),(b)) ((a)<(b))?(a):(b) main() { int i=0,a[20],*ptr; ptr=a; while(min(ptr++,&a[9])<&a[8]) i=i+1; printf("i=%d\n",i);}

3 Answers  


Categories