You and your Research
A highly enlightening and inspiring talk by Richard Hamming about what it takes to do significant research, that I read again after a long time. Find it here.
Somewhere, something incredible is waiting to be known.
Click here to read my blog on data mining
A highly enlightening and inspiring talk by Richard Hamming about what it takes to do significant research, that I read again after a long time. Find it here.
Posted by Anoop Kunchukuttan at 1:36 PM 0 comments
Labels: inspiration, talk
How do you write a C program, which at compile time allows you to input another program at the terminal. When you run the 1st program, the code that you input at the terminal should execute.
Something like:
bash#gcc -o 1 1.c
#incude
{
printf("Let a thousand ideas bloom :)");
}
^D
bash#./1
Let a thousand ideas bloom :)
So write the code for 1.c. Hint: Assume gcc and any UNIX variant as OS.
As it turns out, the solution is a one liner.
#include "/dev/tty"
While compiling, the macroprocessor tries to open and read from the file /dev/tty, just as it would do for any other include like stdio.h. Since /dev/tty is the terminal, you can now input the second program at the terminal. It get compiled and Bingo! you execute code written at compile time.
Posted by Anoop Kunchukuttan at 12:00 PM 4 comments
Labels: C programming gcc linux