#include<stdio.h>#include<stdlib.h>int length( char *p){ int i; i=0; while(*p!='\0') { i++; p++; } return(i);}int main (){ char str[20]; int l; printf("input string:"); scanf_s("%s",str); l=length(str); printf("the length of string is :%d",l); system("pause"); return 0;}
1 回答

來虐小學生
TA貢獻20條經驗 獲得超4個贊
十九行的scanf_s("%s,str"); ? ?這句話報錯。
我改為scanf("%s",str); 就沒有報錯。。。 ? ?
我是新手,不知道你程序的目的是不是這樣。
- 1 回答
- 0 關注
- 1356 瀏覽
添加回答
舉報
0/150
提交
取消