#include <stdio.h>
int main()
{
char grade = 'A';
int *p = &grade;
printf("The address where the grade is stored: %p\n", p);
printf("Grade: %c\n", grade);
return 0;
}
每次在 VScode 上编译代码时都会出现此错误,但从未在代码块上编译。
warning: incompatible pointer types initializing 'int *' with an
expression of type 'char *' [-Wincompatible-pointer-types]
int *p = &grade;
^ ~~~~~~
1 warning generated.
./main
The address where the grade is stored: 0x7ffc3bb0ee2b
Grade: A"