sample code:

lusi (鹭鸶)
char buffer[] = "123456.12";
long number;
number = atol(buffer); // number = 123456
buffer[6] = '\x37'; // '7'
number = atol(buffer); // number = 123456712;

The things to pay attention to is atol() should less than LONG_MAX, otherwise, you'll got garbagge data in number because of overflow error.
(#369068@0)
2002-2-14 -05:00

回到话题: Please help C questions- convert array to unsigned long: I have an array b[0] ='1'; ..b[6]='7'; b[7]=0; I want convert to unsigned long usl; usl = atol(buffer); there is no problem, but ...

回到论坛: HOME枫下论坛枫下论坛主坛工作学习IT杂谈

URL:   
http://www.rolia.net/zh/post.php?f=0&p=369068