Reaching data of differet array using pointer in the loop



My problem is as following. I have 3 arrays named: abee1 , abee2, myarray. I have loop that want to call abee1 , abee2 one each time and copy myarray into it . It means that I reach the name of abee1 to abee2 in the loop for doing this. I made the name of each one by using strings ( abee1 , abee2) in the loop. In the last I want to copy the myarray into the abee1/2 using pointer. I do not know what to do after the line "string arrayname = "abee" + String;". Please help.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include<iostream>
    #include<string>
    #include <sstream>
    using namespace std ;

    int abee1 [4] [4] ;
    int abee2 [4] [4] ;
    int myarray [4] [4] = {{10,0,3,2},{2,0,4,9},{13,0,5,64},{14,0,2,6}};
    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;
                   int *arrayname [] = &myarray
                }
    return 0;
    }
Last edited on
You can't create a string and then use it as the name of an object in C++. It's not a reflexive language.
Topic archived. No new replies allowed.