How can I resolve debug error?
주열 박
0
Reputation points
I used visual studio to code c++.
How can I fix this error?
My code
#include <iostream>
#include <fstream>
#include <string>
int main()
{
using namespace std;
string filename = "C:/Users/park7/Desktop/console/data.csv";
ifstream csv(filename);
string s;
if (!csv.is_open()) {
cout << "파일 열기 실패: " + filename << endl;
return 1;
}
auto old_prec = cout.precision();
cout.precision(3);
while (getline(csv, s)) {
int a, b;
string col1 = "", col2 = "";
if (s == "") continue;
if (s.find(',') == -1) continue;
col1 = s.substr(0, s.find(','));
col2 = s.substr(s.find(',') + 1);
a = stoi(col1);
b = stoi(col2);
cout
<< a << "+" << b << "=" << a + b << endl
<< a << "-" << b << "=" << a - b << endl
<< a << "*" << b << "=" << a * b << endl;
cout
<< a << "/" << b << "=";
if (b == 0)
cout << "0으로 나눌 수 없음" << endl;
else
cout << (float)a / b << endl;
cout << endl;
}
cout.precision(old_prec);
csv.close();
return 0;
}
data.csv
Developer technologies | C++
Developer technologies | C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
Developer technologies | Visual Studio | Other
Developer technologies | Visual Studio | Other
A family of Microsoft suites of integrated development tools for building applications for Windows, the web, mobile devices and many other platforms. Miscellaneous topics that do not fit into specific categories.
Sign in to answer