Code::Blocks

User forums => General (but related to Code::Blocks) => Topic started by: Phred on March 30, 2018, 08:41:59 pm

Title: Code Issue in FOR() loop
Post by: Phred on March 30, 2018, 08:41:59 pm
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;
}
Title: Re: Code Issue in FOR() loop
Post by: oBFusCATed on March 30, 2018, 09:02:41 pm
Type s before size_t. Then search which using unsigned types like size_t is not a good idea. :)