이상한 코드 문제가 있습니다. 비주얼 스튜디오에서 내 '정신병자', '신나라타', 그리고 '내 시스템'은 모두 빨간 물결 무늬가 있으며 모호한 코드로 표시됩니다. 프로젝트는 여전히 정상적으로 컴파일되고 오류나 경고를주지 않지만 성가신 일이며 실제 오류가 발생하는 시점을 알려주지 않습니다. 'if (argc> 0)'부분을 추가하고 제거한 다음 삭제하고 'namespace std;를 사용하여 다시 입력하면 모두 시작되었습니다.' squiggles는 사라진다. 슬프게도 위의 'if'문을 다시 입력하면 문제가 반환됩니다. 나는 정말로 약간의 도움에 감사 할 것이다. 감사합니다.Visual Studio에서 if 문을 추가 한 후 C++ 모호성 오류가 표시됩니다.
if(argc = 0){ // should be ==
하지 컴파일 오류가 있지만, 논리 오류 :
#include <string>
#include <iostream>
#include "chkString.h"
using namespace std;
int main(int argc, char * argv){
int cipher;
int encryption;
string keyPhrase;
string iFile;
string oFile;
chkString chk;
cout << "Hello User!" << endl;
if(argc > 0){
cout << "Hello";
}
if(argc = 0){
cout << "Enter '1' for Vigenere, or '2' for Playfair, or '0' to quit: ";
cin >> cipher;
while(cipher != 1 && cipher != 2 && cipher != 0){
cout << "I'm sorry that is not a valid entry. "
<< "Please retry." << endl <<
"Enter '1' for Vigenere, or '2' for Playfair, or '0' to quit: ";
cin >> cipher;
}
if(cipher == 0){
return 0;
}
cout << "Enter '1' for encryption, '2' for decryption: ";
cin >> encryption;
while(encryption != 1 && encryption != 2){
cout << "I'm sorry that is not a valid entry. "
<< "Please retry." << endl <<
"Enter '1' for encryption, '2' for decryption: ";
cin >> encryption;
}
cout << "Enter the keyphrase: ";
cin >> keyPhrase;
while(!(chk.intCheck(keyPhrase))){
cout << "I'm sorry that is not a valid entry. "
<< "Please retry." << endl << "Enter keyphrase: ";
cin >> keyPhrase;
}
cout << "Enter your output file name: ";
cin >> oFile;
cout << "Enter yout input file name: ";
cin >> iFile;
}
cout << "Hello" << endl;
system("pause");
return 0;
}
'if (argc = 0)'은 실제로 argc에 0을 할당하고 bool 표현식을 false로 변환하며 아무 것도 분기에서 실행되지 않습니다 (게시 된 코드의 대부분). 또한, 'argc'는 카운트에 프로그램 이름을 포함하므로 항상 최소한 1이어야합니다. – SleuthEye
argc는 [일반적으로 결코 0이 될 수 없습니다] (http://stackoverflow.com/questions/8113786/executing-a- process-with-argc-0)을 일반 데스크탑 컴퓨터 환경의 명령 줄에서 시작된 응용 프로그램에 적용합니다. argv [0] 포인터는 일반적으로 실행 된 응용 프로그램의 이름 인 문자열을 가리 킵니다. "command line arguments"는 일반적으로 argv [1]과 그 이후의 위치에있게됩니다. –
제목/태그가 * 실제로 * "Visual Student"인 경우 변경하십시오. – user2864740