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


Please Help Members By Posting Answers For Below Questions

Explain what is the difference between a string and an array?

635


HOW TO SOLVE A NUMERICAL OF LRU IN OS ??????

2265


What are register variables in c?

573


Explain about block scope in c?

660


When would you use a pointer to a function?

587






Why is c so powerful?

683


What are the advantages of the functions?

604


What are structural members?

568


The % symbol has a special use in a printf statement. How would you place this character as part of the output on the screen?

769


Explain what is the most efficient way to store flag values?

694


What is a pointer and how it is initialized?

608


Which of the following operators is incorrect and why? ( >=, <=, <>, ==)

664


What language is windows 1.0 written?

573


What are the types of variables in c?

578


Explain the use of fflush() function?

625