3 ms·
That is true, but my point is that in the context of an interview, the purpose of "char *p;" might simply be to indicate the type of p, but not necessarily to i
by gengkev 10y ago
That is true, but my point is that in the context of an interview, the purpose of "char *p;" might simply be to indicate the type of p, but not necessarily to indicate that it is uninitialized. It's hard to know what the interviewee thought without asking them.
Though it might be a good thing to say "well, p is uninitialized," it might also come across as obnoxious if that wasn't what the interviewer intended. So it comes down to guessing which response the interviewer is looking for.
- eveningcoffee 10y agoI do not know how to convince you as others have failed, but I really believe that trying to understand the correct understanding about the memory allocation was the essence of these questions. The final answer that the memory was dynamically allocated by the compiler is as wrong as it can be. If I saw this code then my first reaction was that this code probably will produce a segmentation fault in the best case scenario. Well, that was after I verified that this is not some pointer usage question, as I am not an experienced C developer.
- adekok 10y ago> the purpose of "char * p;" might simply be to indicate the type of p, but not necessarily to indicate that it is uninitialized. It's C code. Your interpretation is not the one used by the compiler. The point was to catch trivial bugs in code. In this case, the interview didn't.