Author Topic: Code Issue in FOR() loop  (Read 2962 times)

Offline Phred

  • Single posting newcomer
  • *
  • Posts: 2
Code Issue in FOR() loop
« 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;
}

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Code Issue in FOR() loop
« Reply #1 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. :)
(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!]