Q. What is the output of the following code snippet?
Code:
#include <stdio.h>
#include<stdlib.h>
void set(int *to) {
to = (int*)malloc(5 * sizeof(int));
}
void solve() {
int *ptr;
set(ptr);
*ptr = 10;
printf("%d", *ptr);
}
int main() {
solve();
return 0;
}
β
Correct Answer: (D)
The program may crash.