I'm just doing some college exercises in C. currently I'm using vscode with C/C++ to code C in my "native environment".
But when I try to print a deferenced value the GCC throws me warnings at compile time. Look at this:
#include <stdio.h>
#include <stdlib.h>
int main (void) {
int x = 10;
double y = 20.50;
char z = 'a';
int *pointer_x = &x;
double *pointer_y = &y;
char *pointer_z = &z;
double sum = *pointer_x + *pointer_y;
printf("Endereço de x = %i\nValor referência de x = %i\n\n", pointer_x, *pointer_x);
printf("Endereço de y = %i\nValor referência de y = %f\n\n", pointer_y, *pointer_y);
printf("Endereço de z = %i\nValor referência de z = %c\n\n", pointer_z, *pointer_z);
printf("O Valor da soma entre x e y é = %f\n\n", sum);
getchar();
return 0;
}
Warnings that I've got:
format ‘%i’ expects argument of type ‘int’, but argument 2 has type ‘int*’ [-Wformat=]
format ‘%i’ expects argument of type ‘int’, but argument 2 has type ‘double*’ [-Wformat=]
format ‘%i’ expects argument of type ‘int’, but argument 2 has type ‘char*’ [-Wformat=]
What am I doing wrong? I really want to display the reference (i don't want do display the adress) value in the second argument, that's why i've used the deference operator. So i don't understand if this warnings are true or not, can anyone help me with this?