我想用_tcstok標記文件中的行。我能夠將該行標記爲一次,但是當我嘗試第二次對它進行標記時,就會出現訪問衝突。我覺得這跟沒有實際訪問這些值有關,而是取而代之。我不知道如何做到這一點,但。訪問衝突,同時使用_tcstok
感謝,
戴夫
附:我使用TCHAR和_tcstok,因爲該文件是UTF-8。
這是我得到的錯誤:在Testing.exe
在0x63e866b4(msvcr90d.dll)第一次機會異常:0000005:訪問衝突讀取位置0x0000006c。
vector<TCHAR> TabDelimitedSource::getNext() {
// Returns the next document (a given cell) from the file(s)
TCHAR row[256]; // Return NULL if no more documents/rows
vector<TCHAR> document;
try{
//Read each line in the file, corresponding to and individual document
buff_reader->getline(row,10000);
}
catch (ifstream::failure e){
; // Ignore and fall through
}
if (_tcslen(row)>0){
this->current_row += 1;
vector<TCHAR> cells;
//Separate the line on tabs (id 'tab' document title 'tab' document body)
TCHAR * pch;
pch = _tcstok(row,"\t");
while (pch != NULL){
cells.push_back(*pch);
pch = _tcstok(NULL, "\t");
}
// Split the cell into individual words using the lucene analyzer
try{
//Separate the body by spaces
TCHAR original_document ;
original_document = (cells[column_holding_doc]);
try{
TCHAR * pc;
pc = _tcstok((char*)original_document," ");
while (pch != NULL){
document.push_back(*pc);
pc = _tcstok(NULL, "\t");
}
你爲什麼鑄造'字符*'而不是'TCHAR *'?另外,你將'TCHAR'當作'TCHAR *'對待,這肯定是不好的。 –
我擺脫了一些鑄造等。仍是同樣的問題。 – David
明目張膽的不是。寫下它沒有演員,你應該能夠找到錯誤。 –