⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subject_50531.htm

📁 一些关于vc的问答
💻 HTM
字号:
<p>
序号:50531 发表者:goldenfaith 发表日期:2003-08-22 10:11:12
<br>主题:关于atoi
<br>内容:请问atoi怎么用的啊,msdn没看懂,特别是第3个参数<BR>radix<BR>Base of value; must be in the range 2 to 36<BR>哪位能写个简单例子吗,tks<BR>
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:夏天和小凡 回复日期:2003-08-22 10:17:41
<br>内容:很简单啊,字符串转为整数,只有一个参数,怎么跑也来三个呢,你说的不会是_itoa()吧!<BR><BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:风之文章 回复日期:2003-08-22 10:25:35
<br>内容:atoi好像只有一个参数吧!<BR>你问的是itoa吧!<BR><BR>第3个参数,代表进制。(范围为2-36)<BR><BR>#include &lt;stdlib.h&gt;<BR>#include &lt;stdio.h&gt;<BR><BR>void main( void )<BR>{<BR>&nbsp;&nbsp; char buffer[20];<BR>&nbsp;&nbsp; int&nbsp;&nbsp;i = 3445;<BR>&nbsp;&nbsp; long l = -344115L;<BR>&nbsp;&nbsp; unsigned long ul = 1234567890UL;<BR><BR>&nbsp;&nbsp; _itoa( i, buffer, 10 );<BR>&nbsp;&nbsp; printf( "String of integer %d (radix 10): %s\n", i, buffer );<BR>&nbsp;&nbsp; _itoa( i, buffer, 16 );<BR>&nbsp;&nbsp; printf( "String of integer %d (radix 16): 0x%s\n", i, buffer );<BR>&nbsp;&nbsp; _itoa( i, buffer, 2&nbsp;&nbsp;);<BR>&nbsp;&nbsp; printf( "String of integer %d (radix 2): %s\n", i, buffer );<BR><BR>&nbsp;&nbsp; _ltoa( l, buffer, 16 );<BR>&nbsp;&nbsp; printf( "String of long int %ld (radix 16): 0x%s\n", l, <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buffer );<BR><BR>&nbsp;&nbsp; _ultoa( ul, buffer, 16 );<BR>&nbsp;&nbsp; printf( "String of unsigned long %lu (radix 16): 0x%s\n", ul,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buffer );<BR>}<BR><BR><BR>Output<BR><BR>String of integer 3445 (radix 10): 3445<BR>String of integer 3445 (radix 16): 0xd75<BR>String of integer 3445 (radix 2): 110101110101<BR>String of long int -344115 (radix 16): 0xfffabfcd<BR>String of unsigned long 1234567890 (radix 16): 0x499602d2<BR><BR><BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:夏天和小凡 回复日期:2003-08-22 10:25:40
<br>内容:#include "stdlib.h"<BR>#include "stdio.h"<BR><BR>int main(int argc, char* argv[])<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;char buff[20];<BR>&nbsp;&nbsp;&nbsp;&nbsp;int i = 33333;<BR>&nbsp;&nbsp;&nbsp;&nbsp;_itoa(i,buff,10);<BR>&nbsp;&nbsp;&nbsp;&nbsp;printf("%s\n",buff);<BR>&nbsp;&nbsp;&nbsp;&nbsp;return 0;<BR>}<BR><BR>char *_itoa( int value, char *string, int radix );<BR>radix:<BR>2就是表示2进制<BR>10就是表示10进制<BR>你可以试试别的。。。。。。。<BR><BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:ax 回复日期:2003-08-22 10:28:55
<br>内容:atoi 只有一个参数啊,你是什么版本的msdn?
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:goldenfaith 回复日期:2003-08-22 10:44:54
<br>内容:是itoa,写错了~<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 + -