What happens if the following program is executed in C and C++?
#include <stdio.h>
int main(void)
{
const int j = 20;
int *ptr = &j;
printf("*ptr: %d\n", *ptr);
return 0;
}
#include <stdio.h>
int main(void)
{
const int j = 20;
int *ptr = &j;
printf("*ptr: %d\n", *ptr);
return 0;
}
A. Error in both C and C++
B. Warning in both C and C++
C. Error in C but Warning in C++
D. Error in C++ but Warning in C
Answer: Option D
Join The Discussion