simple problem with Vector and Structs

3

Hello, I would like to know why it is not going, I have looked in many places but can not 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;
}

Say this 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)) === |

    
asked by anonymous 07.12.2015 / 18:32

2 answers

1

In this way you are doing the assignment, it is only possible in the declaration of the variable. (or if you make a function for it).

The first error is because you can not assign a value of this mode in the C language.

The second error is syntax, showing that '{}' (keys) do not exist in the assignment of a type of this (integer).

I hope I have helped.

Take a closer look at this link here: https://pt.wikibooks.org/wiki/Programar_em_C/Vetores

Hugs and good studies!

    
07.12.2015 / 19:47
0

As mentioned above, the assignment mode variável = [valores] , in C, can only be used in the declaration of the variable.

Another important point is that even if you had not used {} but [] E the language would allow you to assign value in this way, it would still be incorrect. When doing x.CPF[1] = [valores,aqui] - You are trying to assign an integer array to a single array house.

    
07.12.2015 / 21:29