#include<stdio.h>
int main()
{
	for(;0;)
	printf("Hello");
	return(0);
}

This code should not give any output, but it is printing Hello once. I'm using TC++ 3.0. Is something wrong with the compiler?

If that is your code, then your compiler is broken. It does what it says with gcc.

But if this is your code (note the 1-character difference), then "Hello" is printed once.

#include<stdio.h>
int main()
{
	for(;0;);
	printf("Hello");
	return(0);
}

Now, did you paste what you tried, or did you recite from memory what you thought you tried?

No, I know that the semicolon at the end of for loop is not there. I am very much clear about that. I think that the compiler is faulty. I cannot perceive any other logical explanation. I posted to know if anyone thinks otherwise.

If that is your code, then your compiler is broken. It does what it says with gcc.

But if this is your code (note the 1-character difference), then "Hello" is printed once.

#include<stdio.h>
int main()
{
	for(;0;);
	printf("Hello");
	return(0);
}

Now, did you paste what you tried, or did you recite from memory what you thought you tried?

>I'm using TC++ 3.0.
Why?

>I think that the compiler is faulty.
And? Salem agreed with you if the code you posted is exactly the code you're running. What more are you looking for?

Turbo C Ver 1 also prints, so it's probably a bug at least through ver 3. Borland 5.5 works as expected.

Turbo C Ver 1 also prints, so it's probably a bug at least through ver 3. Borland 5.5 works as expected.

As reported earlier I used TC Version 2.01 and it did not have that problem.

>Salem agreed with you if the code you posted is exactly the code you're running. What more are you looking for?

It is the first time that I came across a problem where it is the compiler's fault. So I just wanted to confirm.

>Turbo C Ver 1 also prints, so it's probably a bug at least through ver 3. Borland 5.5 works as expected.

That is exactly what I found.

>As reported earlier I used TC Version 2.01 and it did not have that problem.

I have not tested it on TC version 2.01. There may be a difference between different versions. No issues from my side.

Since this is now a non-issue because it has been answered (and the specified for statement is really stupid to begin with), to stop the further useless posts this thread is closed.

This question has already been answered. Start a new discussion instead.