私の問題は次のとおりです。abee1 、 abee2 という名前の2つの配列があります。それらを1つずつ呼び出し、各ステップでそれらのデータを出力したいループがあります。これは、データを印刷するためのループで、arrayBee1 の名前から arrayBee2 に到達したいということです。ループ内で文字列 ( abee1 、 abee2 ) を使用して、それぞれの名前を作成しました。
#include<iostream>
#include<string>
#include <sstream>
using namespace std ;
int abee1 [4] [4] = {{5,0,40,30},{6,0,21,47},{7,0,17,63},{8,0,31,62}};
int abee2 [4] [4] = {{1,0,37,52},{2,0,49,49},{3,0,52,64},{4,0,20,26}};
int main()
{
int cc;
for ( cc = 1 ; cc < 3; cc++)
// making the name of nbee1 and nbee2
{ string String = static_cast<ostringstream*>( &( ostringstream () << cc) )->str();
string arrayname = "abee" + String;
// using pointer to have the values of nbee1 or nbee2
string *a = & arrayname;
for ( cc = 0 ; cc < 4; cc++)
cout << *a<<"\n";
}
return 0;
}
「string *a = & arrayname;」に問題があることはわかっています。コードの一部とその後。修正するのを手伝ってください。