怎么查一个数组的实际长读? C语言!

来源:百度知道 编辑:UC知道 时间:2024/05/30 01:29:34
sizeof 能用的上么
include <stdio.h>
#include <string.h>

void fun (char *s, char *t)
{ int i, j, sl;
/************found************/
sl = _1_;
for (i=sl-1, j=0; i>=0; i-=2)
{ if (i-1 >= 0) t[j++] = s[i-1];
if (i-1 >= 0) t[j++] = s[i-1];
t[j++] = s[i]; t[j++] = s[i];
}
/************found************/
_2__;
}

main()
{ char s[100], t[100];
printf("\nPlease enter string s:");
/************found************/
scanf("%s", s);
fun(s, t);
printf("The result is: %s\n", t);
}

sizeof()返回的是所占用内存的大小
实际长度可以用strlen();
记得带上头文件#include <string.h>
那个查找的函数可以用strcmp();
很巧啊!又回答你的问题了 !
Add my qq:448280620

第一个空
sl = strlen(s);
第二个空
t[2*sl] = '\0' ;