Hi, i'm a new guy studing C language, from the begining to now everything goes great, until i write this little program to try to write structures to a file using a float type, and it is here where everything goes wrong! When i compile the program the compiler gives me no erros nether warnings, so everythings goes write, but when i run the program in the dos prompt well ... he gives me a error, he tells me:
RUNTIME ERROR R6002 FLOATING POINT NOT LOADED...
jesus, i've tried everything but he gaves me the same error always, except when i change the float type to an integer.
I'm using these code:
#include <stdio.h>
typedef struct
{
char Nome[30];
int Idade;
float Salario;
} PESSOA;
main()
{
PESSOA x;
FILE *fp;
fp = fopen("Dados.dat", "w+b");
if (fp != NULL)
{
printf("Nome : "); gets(x.Nome);
printf("Idade : "); scanf("%d", &x.Idade);
printf("Salario : "); scanf("%f", &x.Salario);
fseek(fp, 0L, SEEK_END);
if (fwrite(&x, sizeof(x), 1, fp) != 1)
printf("ERRO: Falha na escrita do Registo!!!\n");
}
else
printf("ERRO: Impossivel criar o Ficheiro \"Dados.dat\"\n");
}
can someone help me please???!!!!!!
Sorry for my bad English, i'm a Portuguese and my English it's not very good.
Question
UltraMAX
Hi, i'm a new guy studing C language, from the begining to now everything goes great, until i write this little program to try to write structures to a file using a float type, and it is here where everything goes wrong! When i compile the program the compiler gives me no erros nether warnings, so everythings goes write, but when i run the program in the dos prompt well ... he gives me a error, he tells me:
RUNTIME ERROR R6002 FLOATING POINT NOT LOADED...
jesus, i've tried everything but he gaves me the same error always, except when i change the float type to an integer.
I'm using these code:
#include <stdio.h>
typedef struct
{
char Nome[30];
int Idade;
float Salario;
} PESSOA;
main()
{
PESSOA x;
FILE *fp;
fp = fopen("Dados.dat", "w+b");
if (fp != NULL)
{
printf("Nome : "); gets(x.Nome);
printf("Idade : "); scanf("%d", &x.Idade);
printf("Salario : "); scanf("%f", &x.Salario);
fseek(fp, 0L, SEEK_END);
if (fwrite(&x, sizeof(x), 1, fp) != 1)
printf("ERRO: Falha na escrita do Registo!!!\n");
}
else
printf("ERRO: Impossivel criar o Ficheiro \"Dados.dat\"\n");
}
can someone help me please???!!!!!!
Sorry for my bad English, i'm a Portuguese and my English it's not very good.
Many thanks
UltraMAX.
Link to comment
Share on other sites
6 answers to this question
Recommended Posts