#include<stdio.h>
#include<string.h>
void main()
{
char *str1="Good morning!";
char str2 []="Have a good time!";
char str3 [40],str4;
printf("请输入字符串str3:\n");
gets(str3);
printf(“各字符串长度为:\n”);
printf("str1:%d\n",strlen(str1)); /*用字符指针调用*/
printf("str2:%d\n",strlen(str2)); /*用字符数组名调用*/
printf("str3:%d\n",strlen(str3));
str4=strlen("You are so fine! "); /*用字符串本身调用*/
printf("str4:%d\n",str4);
}
#include<string.h>
void main()
{
char *str1="Good morning!";
char str2 []="Have a good time!";
char str3 [40],str4;
printf("请输入字符串str3:\n");
gets(str3);
printf(“各字符串长度为:\n”);
printf("str1:%d\n",strlen(str1)); /*用字符指针调用*/
printf("str2:%d\n",strlen(str2)); /*用字符数组名调用*/
printf("str3:%d\n",strlen(str3));
str4=strlen("You are so fine! "); /*用字符串本身调用*/
printf("str4:%d\n",str4);
}