| | | | Question Answer Tutorial - Linux->Memory | | | | Question: What is the output of this program?
#include #inlcude int main() { int *ptr; double *ptr; printf("%d ",sizeof(ptr)); return 0; } | | Answer: The compiler will give the error
| | | | | | | | Question: What is the output of this program?
#include #include int main() { char *ptr; ptr = (char *)malloc(sizeof(char)*11); ptr = "MCQTutorial"; printf("%s ",*ptr); return 0; } | | Answer: Segmentation fault
| | | | | | | | Question: What is the output of this program?
#include #include int main() { char *ptr; free(ptr); return 0 } | | Answer: Aborted (core dumped)
| | | | | | | | Question: What is the output of this program?
#include #include int main() { int *ptr1; while(1){ ptr1 = malloc(1024*1024); if(ptr1 == 0) break; sleep(1); printf("MCQTutorial "); free(ptr1); } return 0; } | | Answer: It will print "MCQTutorial" until the process has be en stopeed by any signal
| | | | | | | | Question: What is the output of this program? #include #include int main() { int *ptr1, *ptr2; ptr1 = malloc(4); *ptr1 = 10; *ptr2 = free(ptr1); printf("%d ",*ptr2); return 0; } | | Answer: It will give an error
| | | | | | | | | | | | |