-
-
-
-
-
-
-
-
-
-
-
-
-
-
}
">All the programs are tested under Turbo C/C++ compilers. It is assumed that, Programs run under DOS environment, The underlying machine is an x86 system, Program is compiled using Turbo C/C++ compiler.The program output may depend on the information based on this assumptions (for example sizeof(int) == 2 may be assumed). Predict the output or error(s) for the following:i) void main(){ int const * p=5; printf("%d",++(*p));}
Answer: Compiler error: Cannot modify a constant value. Explanation: p is a pointer to a "constant integer". But we tried to change the value of the "constant integer".
-
-
-
-
-
-
strcpy(obj->pAddress, "Your Address");
free(obj);
printf("%s", obj->pName);
printf("%s", obj->pAddress);
}
">Struct Foo{ char *pName; char *pAddress;};main(){ struct Foo *obj = malloc(sizeof(struct Foo));clrscr(); obj->pName = malloc(100); obj->pAddress = malloc(100); strcpy(obj->pName,"Your Name"); strcpy(obj->pAddress, "Your Address"); free(obj); printf("%s", obj->pName); printf("%s", obj->pAddress);}
A) Your Name Your NameB) Your Address, Your AddressC) Your Name, Your AddressD) None of the aboveExplanation: Prints Nothing, as after free(obj), no memory is there containing obj->pName & pbj->pAddress
C Interview Questions
Ans