home *** CD-ROM | disk | FTP | other *** search
/ PC Shareware 1997 June / PC_Shareware-1997-06.iso / manga / mp2win95 / _setup.1 / my_str_lib.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-05  |  1.9 KB  |  109 lines

  1. #define STRICT
  2. #define WIN32_LEAN_AND_MEAN
  3. #define NOMCX
  4. #define NOIME
  5. #define NOGDI
  6. #define NOUSER
  7. #define NOSOUND
  8. #define NOCOMM
  9. #define NODRIVERS
  10. #define OEMRESOURCE
  11. #define NONLS
  12. #define NOSERVICE
  13. #define NOKANJI
  14. #define NOMINMAX
  15. #define NOLOGERROR
  16. #define NOPROFILER
  17. #define NOMEMMGR
  18. #define NOLFILEIO
  19. #define NOOPENFILE
  20. #define NORESOURCE
  21. #define NOATOM
  22. #define NOLANGUAGE
  23. // #define NOLSTRING
  24. #define NODBCS
  25. #define NOKEYBOARDINFO
  26. #define NOGDICAPMASKS
  27. #define NOCOLOR
  28. #define NOGDIOBJ
  29. #define NODRAWTEXT
  30. #define NOTEXTMETRIC
  31. #define NOSCALABLEFONT
  32. #define NOBITMAP
  33. #define NORASTEROPS
  34. #define NOMETAFILE
  35. #define NOSYSMETRICS
  36. #define NOSYSTEMPARAMSINFO
  37. #define NOMSG
  38. #define NOWINSTYLES
  39. #define NOWINOFFSETS
  40. #define NOSHOWWINDOW
  41. #define NODEFERWINDOWPOS
  42. #define NOVIRTUALKEYCODES
  43. #define NOKEYSTATES
  44. #define NOWH
  45. #define NOMENUS
  46. #define NOSCROLL
  47. #define NOCLIPBOARD
  48. #define NOICONS
  49. #define NOMB
  50. #define NOSYSCOMMANDS
  51. #define NOMDI
  52. #define NOCTLMGR
  53. #define NOWINMESSAGES
  54. #define NOHELP
  55. #define _WINUSER_
  56.  
  57. #include <windows.h>
  58. #include "my_str_lib.h"
  59.  
  60. str_type my_itoa(int value, str_type str, int radix)
  61. // Negative numbers not supported, or radices bigger than 10
  62. {
  63.    int i;
  64.    int last_index;
  65.    int remainder;
  66.    char temp[256];
  67.  
  68.    if (value == 0) {
  69.        str[1] = '\0';
  70.       str[0] = '0';
  71.  
  72.     } else {
  73.  
  74.        temp[255]='\0';
  75.  
  76.        for(i=254; i>=0, value>0; i--) {
  77.           remainder = value % radix;
  78.           value /= radix;
  79.           temp[i] = (char) (remainder + '0');
  80.           last_index = i;
  81.        }
  82.  
  83.        lstrcpy(str, temp + last_index);
  84.    }
  85.  
  86.    return(str);
  87. }
  88.  
  89. int my_atoi(str_type str)
  90. // Negative numbers not supported
  91. {
  92.     int length = lstrlen(str);
  93.    int base = 1;
  94.    int i;
  95.    int result = 0;
  96.  
  97.  
  98.    for(i=length-1; i>=0; i--)
  99.    {
  100.         result += (str[i] - '0') * base;
  101.       base = (base << 3) + (base << 1);  // base*=10;
  102.    }
  103.  
  104.    return (result);
  105. }
  106.  
  107.  
  108.  
  109.