I had gone to an interview in which I was asked the question:
What do you think about the following?
int i; scanf ("%d", i); printf ("i: %d\n", i);
I responded:
- The program will compile successfully.
- It will print the number incorrectly but it will run till the end without crashing
The response that I made was wrong. I was overwhelmed.
After that they dismissed me:
The program would crash in some cases and lead to an core dump.
I could not understand why the program would crash? Could anyone explain me the reason? Any help appreciated.