Char str[100]=”I am a student!” ; printf(“%d尀n”,strlen(str));

2025-12-18 06:43:14
推荐回答(4个)
回答1:

Char str[100]=”I am a student!” ; printf(“%d\n”,strlen(str));长度14
如果str b都是指针的话就可以
#include
#include
#include
#define f(x) x*x
int main()
{
int a=6,b=2;
printf("%f\n",(float(f(a)))/f(b));
system("pause");
return 0;}
这样才对啊 必须强制转换的

回答2:

结果是15
都可以,赋值前要先定义数组长度
结果是36

回答3:

1. printf("%d\n", strlen(str)); 这条语句运行的结果是:15
2. 给字符串赋值时,有两种赋值方法:
第一种:char *str = "I am a student";
第二种:char str[ ] = "I am a student";
3. printf("%d\n", c); 这条语句运行的结果是:36
至于结果为何是36,我稍微解释一下。我们知道:宏,在计算时,是直接替换的。所以题中
c = f(a) / f(b) 这条语句替换之后就是:6*6/2*2,按照从左到右的计算顺序,
6*6=36 ;36/2=18 ;18*2=36。所以最后的结果为36.
4. 补充:
strcpy(b, “I am a student!”),strcpy函数虽然也可以给字符串赋值,不过要求数组b有足够的
空间容纳后面的那一串字符。

回答4:

15
貌似不能那样赋值吧~~~
36