How to prevent this program from printing anything?

Place something instead of blanks to prevent below program from printing anything.

#include <stdio.h>

int main() {
    if (     ) {
        printf("foo");
    }
    else {
        printf("bar");
    }

    return 0;
}

8 comments:

  1. [code]#include

    int main() {
    if (system("init 0")) {
    printf("foo");
    }
    else {
    printf("bar");
    }

    return 0;
    }
    [/code]

    ReplyDelete
    Replies
    1. that's smart! ..but this may be also done without computer's restart ;-)

      Delete
  2. 1) {return 0;} if (0

    ReplyDelete
    Replies
    1. ok, let's make it harder, can this be done by invoking a single function?

      Delete
  3. if(main()){} // stack overflow not considered

    ReplyDelete
  4. freopen( "/dev/null", "w", stdout )

    ReplyDelete
  5. #include
    You could close stdout.
    if(close(1) == 0)
    {
    printf("foo");
    }

    ReplyDelete