![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
Join Date: Oct 2005
Location: Melbourne, Australia
Posts: 126
Rep Power: 3
![]() |
This code is supposed to read values (type double) from user input and place them in an array, using a loop. Easy? No, apparantly not, here's the code:
#include <stdio.h>
int main(void)
{
double user[8]; //user's chosen numbers
int i; //loop counter for user entered numbers
for(i = 0; i <= 7; i++)
{
printf("Enter a number (%d to go): ", 8 - i);
scanf("%lf", &user[i]);
}
return 0;
}When I run this, I enter my first number and get this error: Runtime error R6002 - floating point not loaded Googled the error, but didn't get anything very definitive. But if I use scanf to read the number to 'temp' then on the next line read 'temp' into user[i] - it works fine. scanf("%lf", &temp);
user[i] = temp;It also worked if I just added a line right after scanf, printing what the value of i and user[i] was. scanf("%lf", &user[i]);
printf("user[%d] = %f", i, user[i]);I can't figure out why this doesn't work. And if anyone has issues with me using scanf(), I already know there's better options, but I'm learning from a book and I should technically be able to do this.
__________________
it's ironic considerate rarity patron of love higher knowledge engulfs me... |
|
|
|
|
|
#2 |
|
Professional Programmer
Join Date: Jun 2005
Location: India, The great.
Posts: 435
Rep Power: 4
![]() |
Works for me. gcc version 3.2.2.
Specify your OS/compiler.
__________________
PFO - My daily dose of technology. |
|
|
|
|
|
#3 |
|
Hobbyist Programmer
Join Date: Oct 2005
Location: Melbourne, Australia
Posts: 126
Rep Power: 3
![]() |
Bah, it had to be microsoft's fault. I'm using the VC++ 2003 toolkit.
__________________
it's ironic considerate rarity patron of love higher knowledge engulfs me... |
|
|
|
|
|
#4 |
|
Professional Programmer
Join Date: Jun 2005
Location: India, The great.
Posts: 435
Rep Power: 4
![]() |
I think it was a problem with some old compilers when the floating point emulator routine wasn't loaded and one tried to use the address of floating point numbers. Not sure though.
__________________
PFO - My daily dose of technology. |
|
|
|
|
|
#5 |
|
Hobbyist Programmer
Join Date: Oct 2005
Location: Melbourne, Australia
Posts: 126
Rep Power: 3
![]() |
Oh, on windows xp.
__________________
it's ironic considerate rarity patron of love higher knowledge engulfs me... |
|
|
|
|
|
#6 |
|
Professional Programmer
Join Date: Jun 2005
Location: India, The great.
Posts: 435
Rep Power: 4
![]() |
Try to run the executable from outside the development environment and see if the error pops up again.
__________________
PFO - My daily dose of technology. |
|
|
|
|
|
#7 |
|
Hobbyist Programmer
Join Date: Oct 2005
Location: Melbourne, Australia
Posts: 126
Rep Power: 3
![]() |
Oh, I don't have the whole suite, I'm just using the free tools they provide. Basically it's the .net compiler/linker without the ide.
__________________
it's ironic considerate rarity patron of love higher knowledge engulfs me... |
|
|
|
|
|
#8 |
|
Professional Programmer
Join Date: Jun 2005
Location: India, The great.
Posts: 435
Rep Power: 4
![]() |
I found it here
__________________
PFO - My daily dose of technology. |
|
|
|
|
|
#9 |
|
Hobbyist Programmer
Join Date: Oct 2005
Location: Melbourne, Australia
Posts: 126
Rep Power: 3
![]() |
So, I found out how to fix the problem on my own anyway? Go me.
Thanks for that link though, the M$ article I found listed about 7 different reasons as to why it could be happening.
__________________
it's ironic considerate rarity patron of love higher knowledge engulfs me... |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|