Saturday, February 20, 2010

C Tips: Converting a char array of numbers into a integer

This is a simple tip for those who can't use any C++ libs, when you are programming a uP for example.
It doesn't matter how you got the numbers in that array, the tip here is just how you are going to take them out, in that specific order.

You multiply by 10 and sum them. Line 19.


int main()
   // This is the declaration
   char  nChar[5];

   // I have to assign the numbers to the array
   nChar[0] = (char) 3;
   nChar[1] = (char) 9;
   nChar[2] = (char) 6;
   nChar[3] = (char) 5;
   nChar[4] = (char) 0;

   int numberInt = 0;

   // This is how it is done
   for (int a = 0; a < 4; a++)
     numberInt = (numberInt * 10) + ((int)nChar[a]);

   printf("%d", numberInt);


Wednesday, February 17, 2010

Android Links

I would like to make available some links to anyone who wants to start developing Android apps:
Download the SDK, in my case it was the Linux(i386) version.

This explains how to install it.

This explains how to install the eclipse plugin.

The first demo.

If you have any question, this is the place to find it, if you haven't found it in the docs.

Other links:

I will post here a step by step guide from the installation of the Android SDK, the instalation of the Eclipse IDE, the ADT plugin for eclipse and how to create your first app, the Hello, World!