1
I am unable to assign an address to a pointer variable when it comes to float or char variables, the visual studio brings me the error "C++ a value of type cannot be Assigned to an Entity of type". With the variable int the pointing works normally, in case my variable int x is ok, now the float y and char z of the problem as below.
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
int main()
{
//Declaração das variaveis e inicialização.
int x = 12;
float y = 22.20;
char z = 'u';
int *ponteiro_x, *ponteiro_y, *ponteiro_z; //declaração dos ponteiros
ponteiro_x = &x; //ok
ponteiro_y = &y; //erro
ponteiro_z = &z; // erro
system("pause");
return 0;
}
Thanks for the help.
Yes, you have set onteiro_x, pointer_y and pointer_z as pointer to int, so only
ponteiro_x = &x;
is correct. Statefloat*ponteiro_y; char *ponteiro_z;
that will be correct.– anonimo