2011年11月8日 星期二

strtol

http://www.cplusplus.com/reference/clibrary/cstdlib/strtol/


Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/* strtol example */
#include 
#include 

int main ()
{
  char szNumbers[] = "2001 60c0c0 -1101110100110100100000 0x6fffff";
  char * pEnd;
  long int li1, li2, li3, li4;
  li1 = strtol (szNumbers,&pEnd,10);
  li2 = strtol (pEnd,&pEnd,16);
  li3 = strtol (pEnd,&pEnd,2);
  li4 = strtol (pEnd,NULL,0);
  printf ("The decimal equivalents are: %ld, %ld, %ld and %ld.\n", li1, li2, li3, li4);
  return 0;
}

沒有留言:

張貼留言