Насколько я понимаю, вы хотите прочитать некоторые значения из текстового файла. Вы можете сделать это следующим образом:
int main()
{
std::string textArray[8]; // array to store the data
std::fstream textFile; // creating a file object
textFile.open("text_file.txt", std::ios_base::in); // creating and opening a text file
if (textFile.is_open()) // check to see if file opened sucessfully
{
for (int a = 0; a < 8; ++a)
{
getline(textFile, textArray[a]); // using getline to get the values of the file
std::cout << textArray[a] << "\n";
}
textFile.close(); // closing the files after we're done using it
}
}
Как видите, мы открыли файл и использовали getline()
, чтобы прочитать содержимое этого штрафа и сохранить его в массиве.