程序在C中查找没有函数的字符串长度(Program to find string length without function in C)

优质
小牛编辑
132浏览
2023-12-01

实现 (Implementation)

现在,我们将看到该计划的实际执行情况 -

#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;
}

输出 (Output)

该计划的输出应为 -

Length of string 'TajMahal' is 8