我正在尝试从文件中读取特定数量的单词。
我写了这个,但似乎我做得不对!我很想知道是否有更好的方法。这是我的代码:
FILE* filePointer;
wstring inputString = L"";
wstring wstr = L"";
int position = 0;
_wfopen_s(&filePointer, fileToReadFrom, L"r");
_setmode(_fileno(filePointer), _O_U8TEXT);
wifstream file(filePointer);
getline(file, inputString);
while (inputString[position] != L' ')
{
position++;
}
fseek(filePointer, position, SEEK_SET);//start reading after first word
while (file.good())
{
getline(file, inputString);
for (wsregex_iterator it(inputString.begin(), inputString.end(), biRegx), it_end; it != it_end; ++it)
{
//Filling the bigram container
wstr = (wstring) (*it)[0];
bigramStatMap[wstr]++;
}
}