News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

Code Issue in FOR() loop

Started by Phred, March 30, 2018, 08:41:59 PM

Previous topic - Next topic

Phred

The following code does not stop at zero...it continues to negative numbers and keeps going until manually stopped.  Is there any way to make with work correctly?

#include <stdio.h>
#include <stdlib.h>

int main()
{
    size_t j;

    for( j = 44; j >= 0; j -= 11)
    {
        printf("%d\n", j);
    }
    return 0;
}

oBFusCATed

Type s before size_t. Then search which using unsigned types like size_t is not a good idea. :)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]