I realize a there is an issue with my data overflowing, but my main concern is trying to re run the program at the end to start all over. I've looked through multiple examples through this website, but couldn't really find one that fit my need.
I am not sure if you can see the first part of my code, but I essentially tried to use someones do while example for my program but i just can't figure it out.
If anyone could give any suggestions I would greatly appreciate it!
I'm sure if i keep at it i'll figure it out eventually, but i thought this would be a good question for this website.
Here is my source code:
#include <stdio.h>
int main (void) {
int days;/* user will input number of days light will travel*/
int answer;
char buffer[256];
printf("
" );
printf(" **-**-**-**Welcome to the LIGHT RAY!**-**-**-**
");
printf("
" );
printf(" To get an idea of how unbelieveably fast light is!
");
printf(" come climb aboard the LIGHT RAY!
", );
do
{
printf("
" );
printf("
");
printf(" How many days would you like to travel?
");
scanf("%d", &days);
printf("processing...
" ) /* fictional terminal computing information*/;
sleep(2);
printf("Initializing warp drive...
" );
sleep(1);
printf("3
" ) /* count down sequence*/;
sleep(1);
printf("2
" );
sleep(1);
printf("1
" );
sleep(1);
printf("SHROOOOM!
" );
sleep(1);
int day_time=days * 86400/*86,400 seconds is equal to 1 day*/;
int distance=day_time*186000/*light travels 186,000 miles per second!*/;
printf("Congratulations, you have traveled %lld miles!
",distance);
printf("Would you like another go?(yes, no)
" );
scanf("%s
", buffer );
}while (strcmp(buffer, "yes") !=0);
getchar();
return 0;
}
See Question&Answers more detail:os