Consider the following C program.#include int main(int argc, char *argv[]){ char *temp; strcpy(temp,argv[0]); return 0;}Why is the above code incorrect (i.e., likely to crash)?Write your explanation here:

Respuesta :

Answer:

Pointer temp is never set.

Explanation:

To begin with the #include statement doesn't include anything, however that won't be a problem.

However temp is a pointer that is declared and then read from without having written anything to it.

Not only is the memory address it points to never written to, the address is never set and then attempted to read from. While this might compile, probably with warnings, the machine won't be able to execute it.

Q&A Education