mardi 30 mai 2017

C++ vector of char vectors cannot be printed

I have a c++ vector of char vectors: std::vector<std::vector<char>> ref After putting chars in it (size increases, so chars are there) I cannot print it.

By calling this->ref.back().back() it correctly prints the last char. But if I do ref.at(0).at(pos) or ref[0].at(pos) or ref[0][pos] nothing is printed.

Chars are put in as follows:

while (infile>>c)
    {
        if (c != '>') {
            ref.back().push_back(c);
            curSeqPos++;

        }
        else {
            infile.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );
            ref.push_back(std::vector<char>(USHRT_MAX));

            curSeq++;
            curSeqPos = 0;
        }
     }

Any idea what I am doing wrong? I am a real newbie to C++ and probably missed a reference somewhere. Any help is appreciated!

Aucun commentaire:

Enregistrer un commentaire