Jump to content

Recommended Posts

Posted (edited)

Então no meu caso ponho assim ?

#include <stdio.h>
#define maxFICHA_DE_COMPONENTES 10000
#define maxFICHA_DE_POSTO_DE_TRABALHO 10000
#define maxFICHA_DE_FUNCIONARIO 10000
#define maxFICHA_DAS_OPERACOES 10000
#define maxFICHA_DA_EMPRESA 10000
int numeroFICHA_DE_COMPONENTES;
int numeroFICHA_DE_POSTO_DE_TRABALHO;
int numeroFICHA_DE_FUNCIONARIO;
int numeroFICHA_DAS_OPERACOES;
int numeroFICHA_DA_EMPRESA;
int numeroDATA;

typedef struct ficha_de_componentes
{
int id;
char designacao[50];
char nserie[50];
DATA data;
int garantia;
int id_fornecedor;
int id_fabricante;
char tipo[50];
char condicao[50];
int id_posto_trabalho;
char obs[100];
} FICHA_DE_COMPONENTES;
FICHA_DE_COMPONENTES ficha_de_componentes [maxFICHA_DE_COMPONENTES];
FILE * componentes;
fwrite(ficha_de_componentes, sizeof(ficha_de_componentes), componentes);
Edited by davide92
Posted

Eu pus assim

   FILE *componentes;
   componentes = fopen("ficha_de_componentes.txt","a+");
   fwrite(ficha_de_componentes,sizeof(ficha_de_componentes),componentes);

e deu-me 1 erro

error: too few arguments to function 'fwrite'

Posted

Porque só estás a gravar 1 componente. Mais especificamente, 1 x sizeof(ficha_de_componentes).

“There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.”

-- Tony Hoare

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.