我有一個.txt文件,其中包含我需要處理的數千行浮點值。我不知道每個特定行有多少個值。我想將所有的值存儲在一個數組中。讀取特定行中的值(可變數值)並將它們存儲在數組中
這一切到目前爲止我有:
string line;
int row = 0;
ifstream file_input (input.c_str());
while (getline(file_input, line))
{
row++;
if (row == 8) // if I want to read the 8th line
{
cout << line;
}
}
此代碼打印8號線,這是一個大量的數值完全的所有內容。我想將所有這些值存儲到一個數組中。 我該怎麼做?