社区
C语言
帖子详情
定义char strTest[9],strlen(strTest)=9?
duckcn
2002-03-11 01:25:11
如果字符串strTest没有填满,strlen(strTest)怎么老为9?
怎么求字符串strTest的实际字符数?
...全文
30
8
打赏
收藏
定义char strTest[9],strlen(strTest)=9?
如果字符串strTest没有填满,strlen(strTest)怎么老为9? 怎么求字符串strTest的实际字符数?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
8 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
jollyqiao
2002-03-12
打赏
举报
回复
sizeof(strTest) = 8*sizeof(char)
strlen取得是字符串中实际个数(以'\0'结尾,不包含'\0')
jeckel
2002-03-11
打赏
举报
回复
定义好字符串以后,最好先用memset初始化,然后再赋值就可以得到正确的长度
duckcn
2002-03-11
打赏
举报
回复
小弟做的是Pro*C,不知和这有没有关系??
school
2002-03-11
打赏
举报
回复
strlen(strTest)求出的是输入strTest[9]中的字符串除‘\0'外的实际字符数。
leizhengdeng
2002-03-11
打赏
举报
回复
char strTest[9];
memset(strTest, 0x00, sizeof(strTest));
.....
int len = strlen(strTest);
strlen(strTest)正常的范围是0-8
coolgh007
2002-03-11
打赏
举报
回复
程序有错吧,能给出吗
fangrk
2002-03-11
打赏
举报
回复
#include <iostream.h>
#include <string.h>
int main()
{ char buff[9];
cin>>buff;
cout<<strlen(buff);
}
输入:123
输出:3
blastball
2002-03-11
打赏
举报
回复
=还是==
C++ string 成员函数 length() size() 和 C
strlen
() 的区别
C++ string 成员函数length()等同于size(),但是和 C 库函数
strlen
()有着本质区别,使用时切勿混淆。
C++中string类的length()与size()方法和C语言的
strlen
()函数有什么区别?
char
buf[256]={0}; buf[0]='a'; buf[2]='v'; buf[3]='h'; string
strTest
(buf,6); cout<<"
strTest
[0]:"<<(uint32_t)
strTest
[0]<<"_"<&...
CString,string,
char
*,
char
[],GetBuffer(int)
char
c='A';
char
szCr[]="ABC";
char
*p和
char
p[]??? 参阅:http://topic.csdn.net/u/20080608/21/12a02aab-ce19-4e9c-8e75-6f09da4144f3.html ============================================ std-string、
如何把数据保存成16进制写入文件
#include #include int main(int argc,
char
*argv[]){
char
*
strTest
= "hello world";int
strLen
=
strlen
(
strTest
);int i=0;FILE *fp;if((fp=fopen("text.txt", "wb")) == NULL){printf("file open failed!");return
LoadRunner中截取字符串
LoadRunner中截取字符串 /*strchr和strrchr的...
char
*
strTest
2,*
strTest
3;
strTest
2=(
char
*)strchr(
strTest
1,'t'); //在
strTest
1中顺序查找字符t,当第一次碰到t的时候开始往后截取。 lr...
C语言
69,371
社区成员
243,082
社区内容
发帖
与我相关
我的任务
C语言
C语言相关问题讨论
复制链接
扫一扫
分享
社区描述
C语言相关问题讨论
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章