Tuesday 13 August 2013

Old Compiler Or New?

This program tells you what compiler you are using. If it is a new compiler, __STDC__ (note there are 2 underscores before and after STDC making a total of 4 underscores) is set to 1.
K&R C was the first version of C before ANSI C came along. The old version is supposedly dead, so we probably will never encounter in in our noob C travels, but this program is one of those things that are "Good To Know"...

#include <stdio.h>

main()
{
    if(__STDC__==1)
    {
        printf("ANSI C);
    }

    else
    printf("K&R");
}

No comments:

Post a Comment