📄 subject_40943.htm
字号:
<p>
序号:40943 发表者:泥巴鱼 发表日期:2003-05-22 15:48:48
<br>主题:新手问:如何自动填充字符串?
<br>内容: 字符串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>内容: 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 <memory.h><BR>#include <stdio.h><BR>#include <string.h><BR>void main( void )<BR>{<BR><BR><BR> char temp[] = "This is a test of the memset function";<BR> int iLen;<BR> iLen=strlen(temp);<BR> printf( "Before: %s\n", temp );<BR> memset( temp, '0', iLen );<BR><BR> <BR> /* 12 */<BR> temp[iLen-2]='1';<BR> temp[iLen -1]='2';<BR><BR> printf( "After: %s\n", temp );<BR>}<BR><BR>2003-5-22 17:09:56
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -