Here is a C puzzle I got from Bestin:
You have a magical program `a.c’. When you type `cc a.c’, your compiler appears to hang (ie, you don’t get back the prompt). Now,during this time, you will be able to type any program `b.c’ in the standard input and type Ctrl-D. Once you do this, […]
Entries Tagged as 'Programming'
C Puzzle
June 26th, 2007 · 5 Comments
Tags: Programming
How to write an RFID virus
December 8th, 2006 · No Comments
Andrew Tanenbaum has an interesting idea ….
Tags: Programming
Getting a backtrace from running C code
September 12th, 2006 · No Comments
Came across two interesting GNU libc functions which helps us to get backtraces without using gdb. The backtrace function accepts an array of void*’s and fills it up with return addresses along the call chain - the total number of addresses stored is returned. The backtrace_symbols function accepts this array and returns an array […]
Tags: Programming
Linksys WRT54G experiments - unaligned data access
December 26th, 2005 · No Comments
Read my old entry on the Linux based WRT54G here.
IBM DeveloperWorks has an interesting article about data alignment here
The article says that MIPS h/w doesn’t support unaligned data access. I wrote a program to test this out:
#include <sys/sysmips.h>
#include <signal.h>
void handler(int n)
{
printf(”caught %d\n”, n);
exit(1);
}
main()
{
int a[100];
int *p;
signal(SIGBUS, handler);
p = (char*)a + 1;
*p = 1;
printf(”after unaligned access […]
Tags: OpenWRT/WRT54G · Programming
Challenging programming languages
November 10th, 2005 · No Comments
Most programming languages are hard to *master*, but not really hard to understand. Have you got your favourite exceptions (ie, those languages which are hard even to understand)?
My vote is for Prolog. I tried teaching it a few years back, but had to beat a hasty retreat as I found some parts of it […]
Tags: Programming
Code Reading - The Linux kernel doubly linked list
October 17th, 2005 · 2 Comments
It’s great if students are exposed to professional, high quality code early in their engineering education. The difficulty is in identifying code which challenges the newbie student intellectually but doesn’t fly far above his head. I am trying to build a small collection of code snippets taken from real programs which demonstrates the subtleties […]
Tags: Favourite · Kernel · Programming
Garbage Collection
September 21st, 2005 · No Comments
What a wise man said:
If Java had true garbage collection, most programs would
delete themselves upon execution.
–Robert Sewell
Tags: Programming
Underhanded C Code Contest
September 19th, 2005 · No Comments
First, it was the Obfuscated C code contest where the most obscure program which violates as many rules of style as possible and stresses poor C compilers with bizarre looking syntactical tricks walks away with the prize ….
Now they have the Underhanded C code contest where the most innocent looking program which does something really […]
Tags: Programming
C Puzzles
August 27th, 2005 · No Comments
Tags: Programming
PowerPC Programming Article
August 3rd, 2005 · No Comments
My article on PowerPC programming with GNU/Linux on a Mac-Mini has been published in this month’s Linux Gazette. Check out http://linuxgazette.net/117/pramode.html.
The Mac-Mini is a really cool machine - I will be doing a few experiments with MacOS X in the coming days. Meantime, the box runs Ubuntu Linux happily!
Apple is going the Intel way - […]
Tags: Programming