vendredi 19 août 2016

Terminating loop on keypress

I am working in C trying to print numbers until infinity unless I press a specified key.

So far, I am using getchar() and that has me inputting a value every iteration. I want it to keep flowing until I press the specified key.

I'm trying to figure out how I can do that.

`

while(c != '0')
{
        check = 0;
        for(*check conditions*)
        {
            if(*check conditions*)
            {
                *condition does not match*
                break;
            }
        }
        if(check == 0)
        {
            printf("%d n", i);
            c = getchar();
        }
    i++;

}

`

Aucun commentaire:

Enregistrer un commentaire