// StringLength2.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" int StringLength(char str[]) { int i=-1; while(str[++i]) ; return i; } int _tmain(int argc, _TCHAR* argv[]) { char s[128]; printf("input sth.:"); scanf_s("%s",&s,sizeof(s)); printf("字符总数为:%d\n",StringLength(s)); return 0; }
反汇编:
用指针快,int类型读入和char类型读入不一样。int比char要快。
转载于:https://www.cnblogs.com/wxl845235800/p/10541018.html
原文链接:https://blog.csdn.net/weixin_30342827/article/details/97913442
本站声明:网站内容来源于网络,如有侵权,请联系我们,我们将及时处理。
还没有人抢沙发呢~