若有定义:char a【100】=“verygood”;则strlen的值是多少?

如题所述

strlen返回的是存储的字符byte个数

对于“verygood”是八个字符,所以strlen返回 8


#include <stdio.h>

#include <string.h>


int main ()

{

  char a[256] = "verygood";

  printf ("\"%s\" is %zu characters long.\n", a, strlen(a));

  return 0;

}


温馨提示:答案为网友推荐,仅供参考