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

📄 subject_40943.htm

📁 vc
💻 HTM
字号:
<p>
序号:40943 发表者:泥巴鱼 发表日期:2003-05-22 15:48:48
<br>主题:新手问:如何自动填充字符串?
<br>内容:&nbsp;&nbsp; 字符串char temp[6],被赋的值不定长.需要用0填满空的位置.比如如果temp='12',要求得到的temp是'000012',怎么办?我想的方法是用for循环,给前几位设置成0,方法好像有点......
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:michael 回复日期:2003-05-22 16:16:36
<br>内容:&nbsp;&nbsp;&nbsp;&nbsp;memset(temp,0,6);可以一下清空缓冲区
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:Justin Le 回复日期:2003-05-22 16:25:45
<br>内容://运行通过,看是你要的吗<BR>#include &lt;memory.h&gt;<BR>#include &lt;stdio.h&gt;<BR>#include &lt;string.h&gt;<BR>void main( void )<BR>{<BR><BR><BR>&nbsp;&nbsp; char temp[] = "This is a test of the memset function";<BR>&nbsp;&nbsp; int iLen;<BR>&nbsp;&nbsp; iLen=strlen(temp);<BR>&nbsp;&nbsp; printf( "Before: %s\n", temp );<BR>&nbsp;&nbsp; memset( temp, '0', iLen );<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp; /* 12 */<BR>&nbsp;&nbsp; temp[iLen-2]='1';<BR>&nbsp;&nbsp; temp[iLen -1]='2';<BR><BR>&nbsp;&nbsp; printf( "After:&nbsp;&nbsp;%s\n", temp );<BR>}<BR><BR>2003-5-22 17:09:56

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -