Digital Paint Discussion Board
Digital Paint Community => Other Stuff => Topic started by: ic3y on September 29, 2008, 10:39:33 AM
-
´/* Scanf mit Schleife */
#include <stdio.h>
int main (void)
{
int zahl,r;
do {
printf ("Number: ");
r=scanf("%i",&zahl);
fflush (stdin);
printf("R : %i\n\n",r);
}while(r==0);
printf("Show Number: %i \n",zahl);
printf("Adress from Number : %i \n\n", &zahl);
;return 0;
}
So I need a
do - while
or anything for restart the program.
I tryed it already but nothing works. Maybe i learn C since 4 hours :P.
So when the programm finished the question come:
Want program restart (Y/N)?
By Y the program start again
By N closed the program
I hope you can help me
ic3y
Sry for bad english : D
-
´/* Scanf mit Schleife */
#include <stdio.h>
int main (void)
{
int zahl,r;
do
{
do
{
printf ("Number: ");
r=scanf("%i",&zahl);
fflush (stdin);
printf("R : %i\n\n",r);
}
while(r==0);
printf("Show Number: %i \n",zahl);
printf("Adress from Number : %i \n\n", &zahl);
}
while(stayhere()); // will do the above at least once
return 0;
}
int stayhere(void)
{
int retval = 0;
// return 1 if staying, 0 if not staying
// This place left for you to write Stay or Leave question
return retval;
}