加入<string.h>

使用函式strlen(s)

#include
#include

int main(void)
{
	char s[10];
	scanf("%s",s);
	printf("存放字串總元素個數:%d個\n",sizeof(s)/sizeof(char));
	printf("共使用%d個元素!\n",strlen(s));
	return 0;
}

 

 

arrow
arrow
    文章標籤
    C
    全站熱搜

    東勢厝滴yang 發表在 痞客邦 留言(0) 人氣()