Read scanf's signature more carefully.
You must pass a pointer to the place where it must write the values. You're passing the value instead.
Name:
Anonymous2009-12-05 20:57
Holy fuck nevermind, I am ass retarded.
Name:
Anonymous2009-12-05 20:57
scanf("%d", &num);
Name:
Anonymous2009-12-05 20:59
I'm feeling nice today,so num should be &num.
Now for the complaints
1. Formatting failure
2. No [code] tags
3. Using printf when you don't have formatting to do
4. system("pause");
If you run your program from the command line instead of just executing it from the IDE (I'm assuming you're using one) you don't have to use a delay, since the window doesn't close itself automatically.
Name:
Anonymous2009-12-05 21:34
The i=j thing is just a remnant from when I tried to figure out what I did wrong. Here's another piece of code that I'm having problems with:
#include <stdio.h>
int main(){
float* num;
int i, j;
i=0;
printf("Enter float: \n");
scanf("%f", &num[i]);
i++;
printf("Enter float: \n");
scanf("%f", &num[i]);
printf("Number less than previous. Program ending.\n");
system("pause");
return 0;
}
I know that it probably breaks all sorts of conventions, but it's only a quick practice that I wrote for finals next week. For the life of me I can't figure out why this one is crashing. The program doesn't even reach the second printf statement.
>>9
It's non-portable. And unnecessary unless you are executing the program in an environment where you need to use some stupid work-around to keep the window open just so you can see your program's output.
>>15
I think it's because we have a soft spot for Cee, if he'd used #include<iostream>, cout, cin, etc I imagine he would have received an ungodly amount of abuse.