← 返回列表

C实例 不使用函数计算字符串长度

C实例 不使用函数计算字符串长度 #include <stdio.h> int main() { char s1[] = "TajMahal"; int i = 0; while(s1[i] != '\0') { i++; } printf("Length of string '%s' is %d", s1, i); return 0; }

C实例 不使用函数计算字符串长度

#include <stdio.h>



int main() {

   char s1[] = "TajMahal";

   int i = 0;



   while(s1[i] != '\0') {

      i++;

   }



   printf("Length of string '%s' is %d", s1, i);



   return 0;

}

打开资源 ↗

交流与评论