看板 C_and_CPP 關於我們 聯絡資訊
開發平台(Platform): (Ex: Win10, Linux, ...) Win10 編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出) VC++ 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) N/A 問題(Question): 我使用了fstream 去打開一個檔案 要把 infomation 寫入txt裡 可是都會出了問題 我是利用 下面的網頁來改的 https://goo.gl/Pp7GA3 請參考下列我更改的地方 謝謝 寫入txt寫到某個程度的時候 就會整個stop working 目前我一直找不到原因… 請問有 高手可以幫我解答的嗎? 餵入的資料(Input): 預期的正確結果(Expected Output): 錯誤結果(Wrong Output): 程式碼(Code):(請善用置底文網頁, 記得排版,禁止使用圖檔) while (!SetupDiGetDeviceRegistryProperty(hDevInfo, &DeviceInfoData, ucSPDRP[j], &DataType, (PBYTE)Buffer, BufferSize, &BufferSize)) { if (GetLastError() == ERROR_INSUFFICIENT_BUFFER){ // Change the buffer size. if (Buffer) LocalFree(Buffer); Buffer = (LPSTR)LocalAlloc(LPTR, BufferSize * 2); }else break;// Insert error handling here. { file << cStatus[j]; file << Buffer << "\n"; file.flush(); // } while (!SetupDiGetDeviceRegistryProperty(hDevInfo, -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 211.23.76.67 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1532055899.A.255.html
sarafciel: Buffer補(const char *)轉型試試? 07/20 11:22
jay70120: 這方法試過了 還是一樣寫入都會寫到一定的數量hang掉 07/20 13:53
jay70120: 總覺得有可能buffer 不夠存 但又不知道從哪解… 07/20 13:53