このようなテキストファイルがあるとしましょう
6 3
john
dan
lammar
私は数字を読むことができ、名前は別のファイルにある場合にのみ読むことができます。ただし、ここでは番号と名前が 1 つのファイルに含まれています。最初の行を無視して、2 行目から直接読み始めるにはどうすればよいですか?
int main()
{
vector<string> names;
fstream myFile;
string line;
int x,y;
myFile.open("test.txt");
//Im using this for reading the numbers
while(myFile>>x>>y){}
//Would use this for name reading if it was just names in the file
while(getline(myFile,line))
names.push_back(line);
cout<<names[0];
return 0;
}