[問題] if 判斷字元相等, 非預期執行結果
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
dev c
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
問題(Question):
不知道為什麼輸入都是0和1卻出現error message
餵入的資料(Input):
1111100000
預期的正確結果(Expected Output):
結束程式
錯誤結果(Wrong Output):
ErrorMessage();
ErrorMessage();
ErrorMessage();
ErrorMessage();
ErrorMessage();
ErrorMessage();
ErrorMessage();
ErrorMessage();
ErrorMessage();
ErrorMessage();
程式碼(Code):(請善用置底文網頁, 記得排版)
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
char g[10];
for(int i=0;i<10;i++){cin>>g[i];}
for(int i=0;i<10;i++){
if(g[i]!='0'||g[i]!='1'){ cout<<"ErrorMessage();"<<endl; }
}
system("PAUSE");
return EXIT_SUCCESS;
}
補充說明(Supplement):
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.116.123.175
推
03/23 21:53, , 1F
03/23 21:53, 1F
→
03/23 22:01, , 2F
03/23 22:01, 2F
推
03/23 22:10, , 3F
03/23 22:10, 3F
→
03/23 22:10, , 4F
03/23 22:10, 4F
→
03/23 22:12, , 5F
03/23 22:12, 5F
推
03/23 22:30, , 6F
03/23 22:30, 6F
推
03/23 22:45, , 7F
03/23 22:45, 7F
→
03/23 22:56, , 8F
03/23 22:56, 8F
→
03/23 22:59, , 9F
03/23 22:59, 9F
→
03/23 22:59, , 10F
03/23 22:59, 10F
→
03/23 23:00, , 11F
03/23 23:00, 11F
推
03/23 23:01, , 12F
03/23 23:01, 12F
→
03/23 23:01, , 13F
03/23 23:01, 13F
推
03/24 14:48, , 14F
03/24 14:48, 14F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章