#include #include #include #include #include #include #include #include #include using namespace std; #pragma warning(disable:4996) class WordDB { public: char n[256]; char word[256]; }; void dump(vector& v) { //for (int i = 0;i<26;i++) //cout << v[i].word << endl; } int main(void) { vector db; ifstream ifs("..\\x64\\Debug\\data1.csv"); const int buf_size = 256; char str[buf_size]; if (ifs.fail()) { cerr << "Failed to open file." << std::endl; return -1; } int i = 0; while (ifs.getline(str, buf_size)) { char a[256]; strcpy(a, str); string strr = string(a); string delim = (","); list list_string; boost::split(list_string, strr, boost::is_any_of(delim)); int i = 0; BOOST_FOREACH(string s, list_string) { //cout << s << endl; char strr[256]; WordDB b; int c = 0; if(i == 0) { strcpy(strr, s.c_str()); strcpy(b.word, strr); i++; cout << b.word; } else { strcpy(strr, s.c_str()); strcpy(b.n, strr); cout << "," << b.n << endl; i=0; } db.push_back(b); //memcpy(strr, 0, 256); } } /* vector v; v.push_back(3); v.push_back(4); v.push_back(1); v.push_back(2); cout << "Before sort" << std::endl; dump(v); std::sort(v.begin(), v.end()); cout << "After sort" << std::endl; dump(v); */ return 0; }