Interesting C++ Construct: Reference to Pointer

March 31, 2007

It looks like this:

type *p;
type *&r = p;

r here is a reference to the pointer p. In other words, it works just like the pointer itself, but if you decide to change it, p will change accordingly. r is now just a nickname for p, they are the same object in memory. References can also be used to allow functions to modify their arguments, avoiding the awkward pointer-to-pointer (type **p) construct. Here’s an example:

Read the rest of this entry »

Tip: Check the C/C++ Preprocessor Output

March 30, 2007

Every C/C++ programmer knows that before a program is compiled, the preprocessor parses directives like #include and #define and macros and inserts them into the code, where they are used. But do you know how to see the preprocessor output? Did you know that’s even possible?

gcc -E file.c


g++ -E file.cpp

will do this for you. The -E switch forces the compiler to stop after the preprocessing phase, spitting all it’s got at the moment to standard output.

Note: Surely you must have some #include directives. The included files get preprocessed, too, so you might get lots of output.

My Linux Story, Part 1 – The Beginning

March 30, 2007

Today is a very special date for me. On March 30, exactly two years ago, I first came into contact with Linux ;) But let me start with the beginning. First, it was…
Read the rest of this entry »

Back from Europe…

March 26, 2007

I’ve been to Iaşi in the last 2.5 days, at a programming contest. I’ve been to Romania before they entered the EU, and as a citizen of Moldova I must say things got worse for us. We didn’t need a visa to enter before, but now we need one. The embassy is overwhelmed with visa requests. Interviews are booked for 3 months ahead, I’ve heard. Apart from this, prices and taxes are higher, and people became even more arrogant towards the “non-European barbarians” that we are. One of the few good things I’ve noticed is that computer / electronics prices are lower than ours, and there is a lot more variety in this domain.

Now, what I’ve been most disgusted with. During our stay, our team has been housed (is this the right word for “cazare”?) together with three Romanian guys who listened to manele all the time. They are a disgrace to the music world. Show me a single person who is not an idiot and genuinely likes this genre!

What would you do to fly?

March 22, 2007

Since I’m going away for a few days, in which I won’t be able to update my blog, I’m leaving you with a question to think about. I suspect many people besides me have the longing to fly. What are you willing to do to achieve this dream?

  • Learn to bungee-jump
  • Learn to fly a helicopter
  • Parachute
  • Become a commercial airplane pilot
  • Go into space as a tourist

Some less pleasant (in the long term) possibilities:

  • Take drugs
  • Jump from the top of a building
  • Virtual reality
  • Become a pilot for the military