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 / abhiraj
a = malloc....
this sentence will give the error Lvalue required..
Is This Answer Correct ? | 11 Yes | 0 No |
What is cohesion in c?
What is the benefit of using const for declaring constants?
. 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
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.
write a program for fibonaci series by using while loop in c?
How can I write a function that takes a format string and a variable number of arguments?
what is the advantage of using SEMAPHORES to ORDINARY VARIABLES???
How is null defined in c?
What is hashing in c?
to find the program of matrix multiplication using arrays
#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);}