Unknown programming error
I''m running into the following error message when I run my code (it compiles fine):
(Program Name) has caused an error in MSVCRT.DLL
(Program Name) will now close.
Is anyone able to help me with this? The code bugs out when I put 3 integers into an array (''Nums''). I am running win ME and bloodshed dev-c++ with mingw compiler. The following code compiles fine and runs until the 3 integers are entered:
#include
int main(){
long Count, Nums[50];
int i;
printf("How many numbers would you like to average? ");
scanf("%i", &Count);
printf("Enter the numbers:\n");
for (i = 0;i < Count;i++){
scanf("%i", Nums);
}
return 0;
}
Thanks for any help
There is a mistake in your code. When you do :
You put all your values in Nums[0] because Nums == &(Nums[0]). You should do :
However, even with this bug it runs fine on my computer (no crash). I compiled it with MSVC++ 6.0.
The matter may be that you use %i for long int. Since it works fine with my compiler, I can only guess.![](sad.gif)
Try to add a printf( ...) just after the scanf("%i", &Count); to see if it gets the right value.
|
You put all your values in Nums[0] because Nums == &(Nums[0]). You should do :
|
However, even with this bug it runs fine on my computer (no crash). I compiled it with MSVC++ 6.0.
The matter may be that you use %i for long int. Since it works fine with my compiler, I can only guess.
![](sad.gif)
Try to add a printf( ...) just after the scanf("%i", &Count); to see if it gets the right value.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement