📄 subject_48485.htm
字号:
<p>
序号:48485 发表者:Rikcuo Akira 发表日期:2003-07-31 21:10:55
<br>主题:沒有atoul,有什麼函數可以將char* 轉換成unsigned long
<br>内容:有ultoa()function可以將unsigned long轉換成char*<BR>但是卻沒有atoul,有什麼函數可以將char* 轉換成unsigned long?或是方法<BR>像itoa()就有對應的atoi()
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:泽心 回复日期:2003-08-02 15:28:25
<br>内容:atol(),strtoul()<BR><BR>#include <stdlib.h><BR>#include <stdio.h><BR><BR>void main( void )<BR>{<BR> char buffer[20];<BR> <BR> long l = -344115L;<BR> unsigned long ul = 1234567890UL;<BR> char *string, *stopstring;<BR> double x;<BR> <BR> int base;<BR> <BR> _ltoa( l, buffer, 16 );<BR> printf( "String of long int %ld (radix 16): 0x%s\n", l, <BR> buffer );<BR><BR> _ultoa( ul, buffer, 16 );<BR> printf( "String of unsigned long %lu (radix 16): 0x%s\n", ul,<BR> buffer );<BR> <BR> <BR> string = "3.1415926This stopped it";<BR> x = strtod( string, &stopstring );<BR> printf( "string = %s\n", string );<BR> printf(" strtod = %f\n", x );<BR> printf(" Stopped scan at: %s\n\n", stopstring );<BR> string = "-10110134932This stopped it";<BR> l = strtol( string, &stopstring, 10 );<BR> printf( "string = %s", string );<BR> printf(" strtol = %ld", l );<BR> printf(" Stopped scan at: %s", stopstring );<BR> string = "10110134932";<BR> printf( "string = %s\n", string );<BR> /* Convert string using base 2, 4, and 8: */<BR> for( base = 2; base <= 8; base *= 2 )<BR> {<BR> /* Convert the string: */<BR> ul = strtoul( string, &stopstring, base );<BR> printf( " strtol = %ld (base %d)\n", ul, base );<BR> printf( " Stopped scan at: %s\n", stopstring );<BR> }<BR><BR>}<BR><BR><BR><BR><BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -