• 0

[Problem] - Visual C++ Runtime Error


Question

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

  • 0

From MSDN:

C Run-Time Error R6002

floating-point support not loaded

The necessary floating-point library was not linked.

Possible causes

The program was compiled or linked with an option, such as /FPi87, that requires a coprocessor, but the program was run on a machine that did not have a coprocessor installed.

A format string for a printf or scanf function contained a floating-point format specification and the program did not contain any floating-point values or variables.

The compiler minimizes a program's size by loading floating-point support only when necessary. The compiler cannot detect floating-point format specifications in format strings, so it does not load the necessary floating-point routines.

Use a floating-point argument to correspond to the floating-point format specification, or perform a floating-point assignment elsewhere in the program. This causes floating-point support to be loaded.

In a mixed-language program, a C library was specified before a FORTRAN library when the program was linked. Relink and specify the C library last.

I got your code to compile and run on my machine, so I don't know why it won't work on yours. Is your computer a 486sx? lol!

Link to comment
Share on other sites

  • 0

Thanks for reply weenur!

No man, i'vo got a Athlon Thunderbird 1.2 cpu, but it's a quite strange ... i've tried a example from a portuguese C Language book, the example uses float's type as well and works fine, why ... why in this simples way he didn't work ... dam ... i'm going mad!!!

If you want to see the this example tell me and i'll send it to you!

Once again, thank you very much for trying to help me.

Cheers

UltraMAX.

Link to comment
Share on other sites

  • 0

Add:

x.Salario = 1.1;

to your code somewhere. I've run into this issue before. Basically vc++ doesn't use floating point support if it can't "find" any uses of it. Adding the above line forces it to load floating point support.

Link to comment
Share on other sites

  • 0

Thanks a lot Andareed!!!!! :D

It works fine now !!! :yes:

Just a question if you or someone else who read this post:

Why can't i use in Visual C++ (Console) color, lines, mouse or even a cursor coordenates?

it is possible?

Jesus C it's a little harder, i don't know to work with Visual C++ himself (Gui Mode), but for

what i've seen ... jesus ... it's a "madness", it's very hard ... i think i'll give up for now

until a learn some C++, then ... i'll see if can do something using Visual C++ (Gui Mode) :rolleyes:

Sorry for my bad English!

Cheers

UltraMAX

Link to comment
Share on other sites

  • 0

Many thanks weenur!

I saw that post and help a lot, but after reading those topics, i still can't and i don't know how to draw a line or a rectagle, for example ....

with you help, now i can change the text color and give the cursor coordenates to navigate between lines, once again, thank you! :laugh: :yes:

But ... can you give me a piece of code to explain how can i draw a line or a rectangle? offcourse, if it's possible to do that in console mode.

Cheers

UltraMAX

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.