I decided to help because it has an extraordinary amount of errors in the code. The ideal is to learn one thing at a time, so make only one mistake, learn from it, move on to the next and there will evolve knowledge. When you try to do what is not yet prepared you make many mistakes and do not learn from them. One of the mistakes and not put the code more organized to help better. Programming is a lot of organization, who cannot do this will have difficulties in the profession.#include <stdio.h>
typedef struct {
int id;
char nome[201];
char endereco[101];
char cidade [31];
} Pessoa;
void preencherPessoas(Pessoa pessoas[], int qtde) {
for (int i = 0; i < qtde; i++) {
printf(" Digite o ID do funcionário: ");
scanf("%d", &pessoas[i].id);
printf(" Digite a nome do funcionário: ");
scanf("%s", pessoas[i].nome);
printf(" Digite o endereco do funcionário: ");
scanf("%s", pessoas[i].endereco);
printf(" Digite o cidade do funcionário: ");
scanf("%s", pessoas[i].cidade);
printf(" DADOS DO FUNCIONARIO DE ID %d CADASTRADOS! \n", pessoas[i].id);
}
}
int main() {
printf("Insira a quantidade de funcionários que serão cadastrados: ");
int qtde;
scanf("%d", &qtde);
printf("\nQTD: %d", qtde);
Pessoa pessoas[qtde];
preencherPessoas(pessoas, qtde);
}
See https://ideone.com/bRJIc6 . And https://repl.it/join/sgsffaia-maniero . Also https://github.com/maniero/SOpt/blob/master/C/Function/ArrayPass.c .I gave a name that means something in the kind of structure created. Code is expression, it is important to give good names to things to better understand what you are doing. Every experienced programmer does that, only novice gives no value to this.I put another 1 byte in strings to fit https://pt.stackoverflow.com/q/177619/101 . The sizes are absurdly large and waste a lot of space and any amount of larger data will burst the stack. I'm not going to go into detail, but all that idea of organizing the struct It's wrong and real codes aren't like that. It serves only to understand other things in this little code, keep it in mind.Do not declare global variables unless you have a very large domain of what you are doing, just declare local variables.Give a better name for the function. What would happen if I had to fill something else?If you created a guy then use it not using the struct to declare variables and parameters.No need to pass array by reference because it is already a reference. I would only need to pass this way if I were to change the whole object, which is not the case, even you can't even do it in the planned form.Do not need to declare the variable before its use, in fact this makes the code less readableNames using ALL_CAPS notation should only be used for macros, and still should be avoided. And you don't need to abbreviate so much, use a more common abbreviation.A function that must fill people's data should not ask how many people will be in total. This is the responsibility of another function.If the data is a string then he's already a array, therefore it is already a reference and scanf() asks for a reference, so you do not need to create another reference when you pass this data, it is already naturally what you expect.I created a main() that makes sense.If you didn't understand anything, it's because you jumped too far. Here on the site has almost everything you need to know before continuing.