Tuesday, September 29, 2009

Portable Ubuntu - best of both worlds

In my day by day work I use Windows. Sometimes though, would be great to have also linux.

There are different solutions to achieve this.

  • install as a second operating system and choose one at boot
  • use some virtualization technique (VMware, Vbox, ... others) and run both 
  • use xwindow client or putty to connect to standalone machine with linux
  • use cygwin
  • use MinGW + Msys
  • run Linux under Windows
Depends on whatever you need.

Monday, September 28, 2009

Vector - upgrade

First of all, I realized two things.
One could lead to undefined behaviour and second definitely could lead to undefined behaviour.
It is all about wide known and liked freeing memory without setting variable to null.

Friday, September 25, 2009

Vector - functions like methods

I would like to show different approach to providing methods to the users. Please note that it is only refactoring, functionality remains exactly the same.

So what it is all about? Simple.
Instead of doing this:
vector$getLength(my_v);
one can do that:
my_v->getLength(my_v);
Beside the fact that this is probably more convenient notation, methods will not interfere with those in different modules as user can access them only from object reference. Furthermore, user is able to replace any method with his own in particular object. While it is quite powerful it is not the case (I think) it would be wise to do so.

Vector upgrade

I have fixed some bugs, add a lot stuff and there it is - new version of vector module.

Thursday, September 24, 2009

My bug with printf - who'd help?

There is such code:

#include <stdlib.h>
#include <stdio.h>

int main() {
 int a;
 a = 5;
 int *b = &a;
 long long c = 2;
 printf("C = %lld, A = %d and I expected %d\n", c, *b);
}
And a result is as below:

C = 2, A = 0 and I expected 5

I have experimented a bit but did not found correct format.
Anyone?

Wednesday, September 23, 2009

How to make c more comfortable part 1


This is first part about c language. I would like to provide useful tools which could make a coder's life much easier.

At first I would like to bring you round to use my Vector class-like library instead of regular c arrays as it provides much more flexibility and safety.