Hi dee Ho peeps!
It has been looong since I wrote last pitfall/quiz in here, so I guess it is about the time to continue :)
So at this time I'll just remind you of one nastyish C specific bug - which is easy to avoid by reading the compilers warnings. I've tested it on gcc.
So following code will work on 32 bit machine, but on 64 bit machine you are allowed to expect sudden death... What's the cause?
And as always, you can use comment section to give answers :)
printf("Looks like you had 32bit machine :) \n");
printf("data %d == copydata %d",data[i],copydata[i]);
void * allocateMyMate(size_t size)
So where's the bug?
And even though the free() corresponding to malloc() is missing, do not consider it as a bug at this time. (Naturally it is a bug, but it was not the bug I wrote this question for).
HINTS BELoW! Do Not Look YET ;)
1. With c++ youre safe from this bug.
2. Try compiling and check the compiler warnings!
|All examples||No related posts|
|Explode function in C||ANSI C explode|
|Atomic Operations||(Finnish!) Atomiset Operaatiot (säikeet II)|
|Packed Array||C - optimize memory usage|
|Bitset in C||C - optimize memory usage|
|Trim/Rtrim (examples extended beyond post)||Trim/Rtrim|
|Linked list||No blog posts|
|Lottery machine||You can do OOP in C|