[問題] 計算輸入的字元數
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
DEVC++
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
問題(Question):
我要算數出輸入的字有有幾個??
餵入的資料(Input):
ABCD
預期的正確結果(Expected Output):
4
錯誤結果(Wrong Output):
3
程式碼(Code):(請善用置底文網頁, 記得排版)
#include <iostream>
using namespace std;
int main(){
int c=0,i=0;
char s[20];
cout<<"Input :"<<endl;
cin>>s[20] ;
for(c;c<20;c++){
if(s[c]=='\b'){
break;
}else i++;
}
cout<<"time:"<<i;
system("pause");
return 0;
}
補充說明(Supplement):
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.36.103.253
→
11/29 00:36, , 1F
11/29 00:36, 1F
→
11/29 00:42, , 2F
11/29 00:42, 2F
→
11/29 01:30, , 3F
11/29 01:30, 3F
→
11/29 02:52, , 4F
11/29 02:52, 4F
→
11/29 15:13, , 5F
11/29 15:13, 5F