Skip to main content

C

Flexible reading

Posted in

Experience, is such a thing... wait, I have written this somewhere already... Oh, that's right, in my previous post. Then, lets get right to the problem.

Structure mapping

Posted in

Experience is such a thing, that comes to you as time goes.

Trivial do-while loop

Posted in

You might have seen such code.

do {
// ...
} while (0);

Me personally have seen it a lot and never knew what was this for.

There 2 reasons for doing this:

Problem #3

Posted in

int var = 7;
printf("%f\n", var);

Q: What will this print?
A: Unpredictable behavior

Problem #2

Posted in

static int a = 0, b = 3;
 
int change_a() { return ++a; }
int change_b(int x) { return b+=x; }
 
void func(int x)
{
    static int aa = change_a();
    static int bb = change_b(x);
}

Corrupted reference

Posted in

One of the things that differs a reference from a pointer is the fact that any reference MUST be initialized (just like constants). One might think that this guarantees safe usage of references.

Syndicate content