An agency in a country town has a maximum of 10,000 customers. Create an algorithm that can enter account number, name and balance of each client. The algorithm should print all accounts, their balances and one of the messages: positive / negative. The typing ends when you enter -999 for the account number or when you reach 10,000. At the end, the algorithm should show the total number of customers with negative balance, total agency customers and agency balance.)
Well, I soon thought of using a data structure with the necessary variables to store the requested information to the client N times, each time from a different client. Well, here's my code.
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
typedef struct clientes
{
char nome[50];
int conta;
int saldo;
} clientes;
struct clientes cadastro_cliente (clientes x);
int main()
{
setlocale(LC_ALL,"");
struct clientes x[1000];
int i;
for(i = 0; i < 5; i++)
{
cadastro_cliente(clientes x[i]);
}
}
struct clientes cadastro_cliente (clientes x);
{
printf("Insira o nome completo do titular da conta: ");
scanf("%s", &x.nome);
printf("Insira o número da conta: ");
scanf("%i", &x.conta);
printf("Insira o saldo da conta: ");
scanf("%i", &x.saldo);
}
The code returns me an error while executing, an error already expected because I am not aware of how to pass a structure to a function that would be called N times. I came to this point watching a video on YouTube but can not be doubted. How would you pass a structure to function and call it at main()
whenever requested by the user?