0
I need to change the values of the variables through their pointers but I’m not getting.
#include <stdio.h>
#include <stdlib.h>
//Programa principal
int main()
{//Declaração de variáveis e ponteiros
int x = 0; int*p;
float y = 0; float *l;
char z = 'B' ; char *m;
//Apontamento de ponteiros
p = &x;
l = &y;
m = &z;
//Impressão dos valores antes da modificação
printf("O valor de x antes da modificao eh : %d\n", x);
printf("O valor de y antes da modificao eh : %f\n", y);
printf("O valor de z antes da modificao eh : %\n", z);
//Inserindo valores que os ponteiros devem alocar na memória das variáveis
*p = 70;
*l = 63.70;
*m = 'A' ; //ERRO - Não consigo fazer a inserção do valor deste ponteiro em sua variável
//Impressão dos valores após a modificação
printf("O valor de x depois da modificao eh : %d\n", x);
printf("O valor de y depois da modificao eh : %.2f\n", y);
printf("O valor de z depois da modificao eh : % \n", z);
//Fim do programa
system("pause");
return 0;
}
Note that I can change the values of variables such as int
and float
, but kind char
returns without any content and no longer know how to proceed.
There is no error, what is wrong is something else, it is not formatting correctly: https://ideone.com/XB3bOl
– Maniero
It shows the "B"?
– Pbras
For me gave a Warning in the compilation in the printf line, it seems to have lacked a %c.
– fajuchem
Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful for you. You can also vote on any question or answer you find useful on the entire site (when you have 15 points).
– Maniero
Helped a lot, doubt healed.
– Arthur Simões