Error in last test

Continuing the discussion from Bender - A depressed robot puzzle discussion:

I use the following code to populate a one dimensional array to use as a map

`    int L;
    int C;
    cin >> L >> C; cin.ignore();    
    int s;
    vector<int> t;
    char map[C*L];    
    for ( int i = 0; i < L; i++) {
        string line;        
        getline(cin,line); 
        
        for (int j=0; j < C;j++){              
            
            map[i*L+j]=(line[j]);
            if (map[i*L+j]=='@') s=i*L+j;
            if (map[i*L+j]=='T') {
                t.emplace_back(i*L+j);
            }         
        }      
    }`

Works fine for all apart the last test were a segment error occurs.
Probably the input of the last test isn’t compatible with my solution while all the others are.
I am buffled :<

That’s because you wrote :
map[i*L+j]=(line[j]);

instead of :
map[i*C+j]=(line[j]);

Oh heck I would have never checked it ! Thanks a lot ! I guess thats what fresh input can give you :slight_smile: