Q:

Tricky for Loop

I am bothered by a question of for loop in C language.
when i write:
#include<conio.h>
#include<stdio.h>
main()
{
    int i = 0;
    for( ; i ; )
    {
        printf("In for Loop");
    }
    getch();
}

Output: NOTHING PRINT.
Code get executed, but printf statement didn't print due to condition. OK, No problem here.
But when i write this code:
#include<conio.h>
#include<stdio.h>
main()
{
    for( ; 0 ; )
    {
        printf("In for Loop");
    }
    getch();
}

Output: In for Loop.
My for loop get executed 1 time, but actually it must not to be executed. I don't know why? can coder/programmer/hacker of stackoverflow help me. explain me please why my for loop giving this output only one time.

A:

What you wrote shouldn't print anything, but I suspect the actual second-case code (not what you typed in) that causes the problem is:
for( ; 0 ; );     // <==== note the trailing semicolon there.
{
    printf("In for Loop");
}

In this case the for loop doesn't execute the empty statement, and then the { } code is executed once.
EDIT: If this isn't the problem please just paste a complete program that exhibits the problem directly into your question.
EDIT2:
The following minimal compilable example doesn't print anything:
#include <cstdio>

int main()
{
    for( ; 0 ; )
    {
        std::printf("In for Loop");
    }
}

