我正在尝试创建一个代码,通过csv数据库解析库存信息.目前,我已生成代码,以便它将使用关键字进行搜索并打印整行,但我正在尝试获取它,以便以整齐格式化的方式打印带有标题行的整行.
我试图得到它,以便如果我搜索谷歌,它会回来
Symbol GOOG
NAME Google Inc
今日高位$ 568.77
csv如何看起来像:
符号,名称,价格,今日高点,今日低点,52周低点
Google,Google Inc.,$ 568.77,$ 570.25,$ 560.35
AAPL,Apple Inc.,$ 93.28,$ 63.89,$ 99.44.
码:
string NameSearch::getInput()
{
cout << "Enter the name of the company you would like to search for: ";
getline(cin, input);
return input;
}
void NameSearch::NameAlgorithm()
{
string line;
ifstream fs("Stock Database.csv");
while (!fs.eof())
{
getline(fs, line);
string companyname = "";
string a;
int column = 1;
int commacount = 0;
int ChrCount = 0;
while (line != "\0") …Run Code Online (Sandbox Code Playgroud)