Daily One Algorithm
A blog dedicated to those who live, drink and eat Algorithms.
Wednesday, July 12, 2006
C or C++
Write a program that will print "C" if compiled as an (ANSI) C program, and "C++" if compiled as a C++ program.
$cat a.c
#include
int
main ()
{
char ch[][5]={"C++","C"};
printf ("%s \n",ch[( 2 //*
/ 2) -1] // */ 1) -1]
);
return 0;
}
$cc a.c ; ./a.out ????
$cc -ansi a.c ; ./a.out ????
Contributed by -KC
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment