C led 4 digit display fatal run time error :S

Status
Not open for further replies.

ukpc5

New Member
hi i'm currently getting a fatal run time error with my program im trying to use while loops to print the stdin horisotaly in 0's in the stdout


#include <stdio.h>

int main( void )
{
int number1, number2, number3, number4, num1;
scanf("%d%d%d%d" , &number1, &number2, &number3, &number4);
printf("%d%d%d%d" , number1, number2, number3, number4);
if(number1 == 1)
num1 = 1;
if(number1 == 2)
printf("%d" , number1);
if(number1 ==3)
printf("%d" , number1);
if(number1 == 4)
printf("%d" , number1);
if(number1 == 5)
printf("%d" , number1);
if(number1 == 6)
printf("%d" , number1);
if(number1 == 7)
printf("%d" , number1);
if(number1 == 8)
printf("%d" , number1);
if(number1 == 9)
printf("%d" , number1);

while (num1 = 1)
{
printf("00 /n" );
printf(" 0 /n");
printf(" 0 /n");
printf(" 0 /n");
printf("000/n");
num1= num1 - 1;}
return 0;}




i do relise that the print f will print the stdin as well as the hopefully print the while loop
as im slighty experimenting hopfully someone can correct me as the fatal runtime error is stopping me
 
yeah at the mintue i've got it setup to only work with the the `1st number if its 1 just trying to get that to work first before i move the others however its errored
 
What do you mean by error-ed ? does it compile ? or does it not run well ?
What does it output ?
 
it spends a while trying to compile and the gives me a fatal run time error i thought this was due to the loop repeating meaning it could never end so i threw in the num1 reset at the end of the loop so it wouldn't repeat however i still have the error
 
When you execute "while (num = 1)"
You actaully put the value 1 into the variable num.
So you get an infinite loop.
you probably meant to use "while (num == 1)".
If a loop runs only once its the same as an IF statement.
 
Last edited:
this questions has been solved thanks to very helpful people including people in chat who also helped by correcting my ////'s with \\\\'s thanks guy your help has been great
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…