私はC++が初めてです。私の最初の目標は、成功する電卓プログラムを Win32 コンソール アプリケーションにすることですが、エラーが発生し続けます。私はこのコードを入れます:
cout << "Do you want to continue? N/Y" << endl;
cin >> ny;
if (ny == "Y") goto start;
if (ny == "N") goto end;
しかし、それはどちらの方法でも終了し続けます。
これは「終了」のコードです。
// End - Properties
system("cls");
system("title Basic Calculator - End");
system("color 4F");
// End - Start
ny == "0";
cout << "Are you sure you want to end? N/Y" << endl;
cin >> ny;
if (ny == "N") goto start;
cin.get();
return 0();
そして最後には、常にプログラムも終了します。
間違いを見つけたら、私に知らせてください。
-デンマークのユメール
完全なコード:
#include <iostream>
using namespace std;
int main()
{
start:
// Program - Properties
system("cls");
system("title Basic Calculator - Main Screen");
system("color 1F");
// Program - Setup
int input;
int x;
int y;
char ny [10];
// Program - Start
cout << "Please choose an operation from the following." << endl << endl;
cout << "1. Addition \n2. Subtraction \n3. Multiplication \n4. Division" <<endl << endl;
cin >> input;
if (input = 1) goto addition;
if (input = 2) goto subtraction;
if (input = 3) goto multiplication;
if (input = 4) goto division;
cin.get();
addition:
// Addition - Properties
system("cls");
system("title Basic Calculator - Addition");
system("color 2F");
// Addition - Start
cout << "Please input your first number." << endl;
cin >> x;
cout <<endl << "Please input your second number."<< endl << endl;
cin >> y;
cout <<endl <<endl << "The answer is " << x+y << ".\a" << endl << endl;
cout << "Do you want to continue? N/Y" << endl;
cin >> ny;
if (ny == "Y") goto start;
if (ny == "N") goto end;
cin.get();
subtraction:
multiplication:
division:
end:
// End - Properties
system("cls");
system("title Basic Calculator - End");
system("color 4F");
// End - Start
ny == "0";
cout << "Are you sure you want to end? N/Y" << endl;
cin >> ny;
if (ny == "N") goto start;
cin.get();
return 0();
}