Не могу понять, откуда эта ошибка. Пытаюсь следовать примеру руководства, но моя версия не работает. В чем дело?
libc++abi: terminating with uncaught exception of type std::invalid_argument: stoi: no conversion
https://www.geeksforgeeks.org/csv-file- ... t-using-c/
// C++ function
void read_record()
{
// File pointer
std::fstream fin;
// Open an existing file
fin.open("reportcard.csv", std::ios::in);
// Get the roll number
// of which the data is required
int rollnum, roll2, count = 0;
std::cout rollnum;
// Read the Data from the file
// as String Vector
std::vector row;
std::string line, word, temp;
while (fin >> temp) {
row.clear();
// read an entire row and
// store it in a string variable 'line'
getline(fin, line);
// used for breaking words
std::stringstream s(line);
// read every column data of a row and
// store it in a string variable, 'word'
while (std::getline(s, word, ',')) {
// add all the column data
// of a row to a vector
row.push_back(word);
}
// convert string to integer for comparision
roll2 = stoi(row[0]);
// Compare the roll number
if (roll2 == rollnum) {
// Print the found data
count = 1;
std::cout
Подробнее здесь: https://stackoverflow.com/questions/682 ... oi-no-conv
Завершение с неперехваченным исключением типа std::invalid_argument: stoi: без преобразования ⇐ C++
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Анализ не работает: завершение вызова после создания экземпляра «std::invalid аргумента»
Anonymous » » в форуме C++ - 0 Ответы
- 114 Просмотры
-
Последнее сообщение Anonymous
-