Showing posts with label c. Show all posts
Showing posts with label c. Show all posts

Sunday, April 4, 2010

Syntax Highlighter to the web

    I was searching for a syntax highlighter to use in a IDE in the company where I work and I have found this web site:

http://quickhighlighter.com/

    It is amazing, just select the language, paste your code and press the Highlight! button just bellow the code box.
    You will see how it is going to look like. If you like, press Toggle Code View and you will get the html code ready to use.

    There are some options at left side of the code box like if you want to show line numbers in your code...

Renan

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.


#include 

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);
}


Renan