# C語言題庫-082 寫一個函數,求一個字符串的長度,在main函數 中輸入字符串,並輸出其長度。 【參考答案】 ``` main() { intlen; char *s tr[20]; printf(“please input a string:\n”); scanf("%s",str); len=length(str); printf(“the s tring has %d characters.”,len); getch(); } length§ char *p; { int n ; n=0; while(*p!=’\0’) { n++; p++; } return n; } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up