Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

trouble with while

tek-69tek-69 Member Posts: 5
[b][red]This message was edited by tek-69 at 2004-8-30 11:16:33[/red][/b][hr]
// By Tek-69
//

#include
#include


int main()
{
int mainloop;
char owner[30];
char petname[30];
char acommand[20];
const quit;

printf("########################
");
printf("#Welcome to LinTel Pet.#
"); // The title screen
printf("#Version 1.0 By: Tek-69#
"); // obviously
printf("########################
");
printf("
");
printf("
");
printf("
");
printf("What's your name?", owner);
scanf("%s", &owner);
printf("Hi %s.
", owner);
printf("What would you like to name your pet?", petname);
scanf("%s", &petname);
printf("%s it is then.
", petname);
printf("Now entering the main loop.
"); //test message remove me later.
mainloop=1;
while (mainloop==1);
{
printf("In the loop.
"); //test message remove me later.
mainloop=1;
// printf("", acommand);
// scanf("%s", &acommand);
// if (acommand == 'quit')
// {
// mainloop = 0;
// printf("Now Quitting. Goodbye.
");
// }
}
return ;
}


Everything works fine, until the while statement. The "entering main loop" message displays as it should, but once it seems to be in the loop
it doesn't display the "in the loop" message. I thought it would repeat "in the loop" over an over infinitely but it just shows a blank line instead. What did i do wrong? Any help would be great :)
thanks, tek


Comments

  • stoberstober Member Posts: 9,765 ✭✭✭
    :
    : Everything works fine, until the while statement. The "entering main loop" message displays as it should, but once it seems to be in the loop
    : it doesn't display the "in the loop" message. I thought it would repeat "in the loop" over an over infinitely but it just shows a blank line instead. What did i do wrong? Any help would be great :)
    : thanks, tek
    :

    looks like the loop is ok, the problem is that the loop executes so quickly the screen doesn't have time to update itself before your program rewrites the same line. Replace the "
    " with just "
    " and see if it fills up the screen with "in the loop".
  • tek-69tek-69 Member Posts: 5
    :
    : looks like the loop is ok, the problem is that the loop executes so quickly the screen doesn't have time to update itself before your program rewrites the same line. Replace the "
    " with just "
    " and see if it fills up the screen with "in the loop".
    :

    that didnt work but i had my friend look at it when he got home an he noticed i had a semicolon where i didnt need one, while (blah blah);
    always some mundane detail :P
    thanks for tryin to help me out though.
Sign In or Register to comment.