This is because you declared the vectors in the inner scope of the if
. You need to move the declaration out, so that your while
loop can see them as well:
vector<string> seqNames;
vector<string> sequences;
if (inputFile.is_open()) {
string currentSeq;
string line;
while (getline(inputFile, line))
{
if (line[0] == '>') {
seqNames.push_back(line);
}
}
}
for( int i = 0; i < seqNames.size(); i++){
cout << seqNames[i] << endl;
}