Advertisement
PierrotLL

PrintInt

Jun 29th, 2011
414
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.85 KB | None | 0 0
  1. #include <fxlib.h>
  2.  
  3. void PrintInt(int n) {
  4.     unsigned char str[12] = "0";
  5.     int i, l=0;
  6.     if(n) {
  7.         if(n<0) {
  8.             str[0] = '-';
  9.             l++;
  10.             n *= -1;
  11.         }
  12.         for(i=n ; i ; i/=10)
  13.             l++;
  14.         str[l] = 0;
  15.         for(i=n ; i ; i/=10)
  16.             str[--l] = i%10 + '0';
  17.     }
  18.     Print(str);
  19. }
  20.  
  21. void PrintIntHex(unsigned int n) {
  22.     char str[11] = "0x";
  23.     int i;
  24.     for(i=0 ; i<8 ; i++) {
  25.         str[9-i] = (n&15) + ((n&15)>9 ? 'A'-10 : '0');
  26.         n >>= 4;
  27.     }
  28.     Print(str);
  29. }
  30.  
  31. int AddIn_main(int isAppli,unsigned short OptionNum) {
  32.     int key, i;
  33.     i = 123456789;
  34.     locate(1, 1);
  35.     PrintInt(i);
  36.     locate(1, 2);
  37.     PrintIntHex(i);
  38.     GetKey(&key);
  39.     return 1;
  40. }
  41.  
  42. #pragma section _BR_Size
  43. unsigned long BR_Size;
  44. #pragma section
  45. #pragma section _TOP
  46.  
  47. int InitializeSystem(int isAppli,unsigned short OptionNum)
  48. {
  49.     return INIT_ADDIN_APPLICATION(isAppli,OptionNum);
  50. }
  51. #pragma section
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement