私は2つの数字mとnを入力として受け取り、m番目の数字のn番目の桁を与えます。例M = 1358、N = 2出力:5エラー:変数がこのスコープで宣言されていませんでした。C++
#include <iostream>
#include <string>
using namespace std;
int main(){
while(true){
int m = 0,n = 10;
char check;
while(true){
cout << "Enter please number m and which digit you want to select";
cin >> m >> n;
string m_new = to_string(m);
if(m_new.length() > n)
break;
else
cout << "n must be less than or equal to m";
}
cout << "The position" << n << "Of integer" << m << "is:" << m_new.substr(n,1);
cout << "Do you want to try again?(y/n)\n";
cin >> check;
while(check != 'y'&& check != 'n'){
cout <<"Please enter y or n\n";
cin >> check;
}
if(check == 'n'){
break;
}
}
return 0;
}
しかし、私はエラーました: 'm_newは' このスコープで宣言されていませんでした。なぜこのエラーが発生し、それを修正するのですか?
@DreamsOfElectricSheepありがとうございます(同時にスポーツを見ようと私に奉仕します...) – Steve