我正在尝试创建一个代码来从文件中读取并计算上述单词在.csv文件中的迭代次数,然后将其输出到屏幕。我正在使用Xcode并继续得到(11db)错误。有人请帮忙!
短.csv文件提取
28/02/17 07:25 b"I'm done goodnight"
28/02/17 07:14 b'If I could loop the sound of my tiny dog drinking water so delicately it would make me this emoji: \xe2\x98\xba\xef\xb8\x8f'
28/02/17 02:33 b'About last night...\xe2\x9c\xa8\xf0\x9f\x8d\xab @jpgaultier @vanityfair
27/02/17 20:01 b'Last night was wild! Even I woke up with an #Oscar! (harharharhar)
27/02/17 05:51 b"You're a winner KP
27/02/17 05:12 b'WHAT WAIT OMG'
27/02/17 05:12 b'KATY HERE. I lost a bet for best picture (I wanted moonlight...'
27/02/17 05:10 b'I just want to say VICE is the best thing ever and Shane smith has a fine head of hair.'
27/02/17 03:37 b'RT @RheaButcher: Ever. In 2017.
26/02/17 23:19 b'GET OUT and see "Get Out" ASAP! Love my girl aw in it
代码
#include <stdio.h>
#include <cstring>
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream fin("/Users/williamthatcher/Desktop/TwitterFeed/sampleTweets.csv"); //opening text file
int count=0;
char ch[20],c[20];
cout << "Enter any word you want to count:";
cin>>c;
while(fin)
{
fin>>ch;
if(strcmp(ch,c)==0)
count++;
}
cout<<"Occurrence of word" << c << " = " << count << endl;
fin.close(); //closing file
return 0;
}