Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

smogsy

macrumors 6502a
Original poster
Jan 8, 2008
592
2
#include <stdio.h>

int main ()
{ /*Most Important Part of the application*/

int Number; /*My Varibiles*/

/*Output Text*/
printf ("Hello Welcome to my First Application\n Please Input a Number Between 0 & 10\n");

/*input Text*/
scanf("%d",Number);

/*Tells them Their Number*/
printf("Your Number is" "%d",Number);

printf("OK You selected %d Correctly",Number);



return 0;
}

it runs ok but when inputting a number it goes to next line as it should but displays bus Error

thanks.
 

toddburch

macrumors 6502a
Dec 4, 2006
748
0
Katy, Texas
Try this:
Code:
scanf("%d",[color=red]&[/color]Number);
After you change it and see that it now works, come back here and tell me why so I know you understand why that fixed it.
 

Darkroom

Guest
Dec 15, 2006
2,445
0
Montréal, Canada
besides missing the &number pointer...

Code:
/*Tells them Their Number*/
printf("Your Number is" "%d",Number);

weird quotes in there?

try:

Code:
/*Tells them Their Number*/
printf("Your Number is %d", Number);

you can also use %i for integers... i always found using %d a little odd, although it's way common, and they both do the exact same thing, i just find it easier to associate Integers with the letter I...

and don't forget the newline character "\n" after your sentence so the 2 output sentences don't run together:

Code:
printf("Your Number is %d[COLOR="Red"]\n[/COLOR]", Number);
 

toddburch

macrumors 6502a
Dec 4, 2006
748
0
Katy, Texas
Well, it is errant, but that's not the output the OP will get:

Code:
[i]Hello Welcome to my First Application
 Please Input a Number Between 0 & 10[/i]
[b]4[/b]
[i]Your Number is4OK You selected 4 Correctly[/i]
The Debugger has exited with status 0.
 

smogsy

macrumors 6502a
Original poster
Jan 8, 2008
592
2
it works after inserting the & any reason why it saying 90k? the first time?

Your Number is 9OK You selected 9 Correctly
sorry still learning :D
 

itickings

macrumors 6502a
Apr 14, 2007
947
185
it works after inserting the & any reason why it saying 90k? the first time?

It is actually saying 9 and then OK immediately afterwards. You have to specifically tell the computer to advance to the next row. If you don't, it will continue to write stuff directly after the last displayed character.
Code:
printf("Your Number is %d[B]\n[/B]",Number);
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.