[Bug c++/31735] New: Problem using <string> STL

leonardo dot anversi at gmail dot com gcc-bugzilla@gcc.gnu.org
Sat Apr 28 17:41:00 GMT 2007


Hi,

I must tried to run an program in g++ 4.1.1, and it gives an wrong answer.
This problem does not occur in g++ 2.95.
I using debian etch.
Se the C++ code below:

////////////////////////////////////////////////////begin-code/////////
#include<iostream>
#include<string>
using namespace std;

int main(){

        int  n, nn; 
        string vector[54], word;

        cin >> nn;
        for (int i=0; i<nn; i++){
                cin >> word;                    
                for (int j=0; j<word.size(); j++){ vector[i][j] = word[j];}
        } 
        for (int k=0; k<nn; k++){                       
                for (int l=0; l<word.size(); l++){ cout << vector[k][l];}
                        cout << endl;
                }
        }
        return 0;
}
////////////////////////////////////////////////////end-code//////////////

As you can see, if you run the program and give any input, it gives you only
the last input.

But if you run with g++-2.95, there's no problem.


Thanks.


-- 
           Summary: Problem using <string> STL
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: leonardo dot anversi at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31735



More information about the Gcc-bugs mailing list