3
Hi, I’d like to know why you’re not going, I’ve searched a lot of places but I can’t find
in C
#include <stdio.h>
typedef struct ficha_pessoal{
int idade;
char sexo;
int CPF [11];
int CPFc [3];
float salario;
char nome [40];
} FICHA;
int main(){
FICHA x;
x.idade=32;
x.sexo = 'M';
x.nome[40]= "JOSE DA SILVA";
x.salario =850;
x.CPF[1] = {5,3,1,9,8,7,0,0,,1,4,1};
printf("%d",x.CPF[1]);
return 0;
}
says so in error
||In Function 'main':| |18|Warning: assignment makes integer from Pointer without a cast [enabled by default]| |20|error: expected Expression before '{' token| ||=== Build failed: 1 error(s), 1 Warning(s) (0 minute(s), 0 Second(s)) ===|
Check that the value you are passing to the CPF is correct.
– DiegoAugusto
"JOSE DA SILVA"
is the typeconst char *
, andx.nome
is the typechar []
. Always remember that arrays and pointers are very different types. To copy a string to an array usestrncpy()
. In this case do:strncpy(x.nome, "JOSE DA SILVA", 40);
and do the#include <string.h>
– ViniciusArruda