Tuesday, July 24, 2007

using Bit Fields

There was a question, as to write a program in C, which
when supplied 0, would print 1, and on being supplied 1
would 0. You are not to use, bit wise operators, i conditions, ternary operators. Below is my attempt at it.

#include
#include

int main(int argc, char *argv[])
{
struct packed_struct {
unsigned int f:1;
} pack;


pack.f = atoi(argv[1]);
pack.f++;

fprintf(stderr, " %d \n", pack.f);

return 0;
}

This works for me ;-)

Saturday, July 14, 2007

The Empire Strikes Back !

I was talking with a friend of mine, who is a
die hard softie(MS zealot), and I casually
mentioned that MS is going to go down, and cannot
survive the Linux onslaught. On hearing this, he
he disagreed, and said that MS is going strong,
and coming up with new things. He said for e.g.
see www.surface.com, he gave a brief, like they
have came up with a board, and if you keep your
camera on that board, all the pics from that
camera are transferred to the board, and on the
flick of a finger, you can transfer all those
pics from the board to your mobile camera.
I had a look at the site, and it was _amazing_.
I recommend you to have a look at it, it is
a breakthrough thing, and you will have a hard
time describing it. A truly breakthrough
innovation. I think after PC's and the mobile
revolution, this is one major innovation.
This is real sci-fi stuff.

Wednesday, July 11, 2007

Coding in Pre-Internet days

Nowadays, it has become a common practise among programmers,
to search google for any problem they face. Recently one of
my colleague asked me, hey how did people used to work, when
there was no google (read WWW and search engines). Since I
was busy with something I didn't thought much about it.
Later, while pondering over the discussion, I remembered, in
the pre internet days, programmers used to rely much on
manuals, even now, many of the veteran programmers who
started coding prior to launch of www, do rely on man pages
a lot.

Also it came to my mind, that earlier when a naive(basic/
stupid) query was asked, the answer used to be RTFM (Read
the F* manual), which has now changed to STFW(Search the F*
web) Times have changed, and so have the acronyms :-)



Luckily or unluckily when I started learning C, and Unix,
around 97, our lab didn't had access to internet, and hence
I had to rely on man pages, and that was fun. So it feels
good to be part of both worlds (rtfm and stfw :-)