Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual c++ 由于写入延迟,无法用于第二次迭代_Visual C++ - Fatal编程技术网

Visual c++ 由于写入延迟,无法用于第二次迭代

Visual c++ 由于写入延迟,无法用于第二次迭代,visual-c++,Visual C++,我的代码的IF-THEN不适用于第二次迭代。这是因为,jar处理需要一些时间将其结果写入output.txt中 由于编写有点晚,我的代码的第二次迭代将始终读取output.txt中以前写入的值,以便将其传递给IF-THEN 例如,在第一次迭代中: output.txt-->0.9888 twrite.txt-->消息:确定 第二次迭代: output.txt-->0.5555 twrite.txt-->消息:正常 //IF-THEN仍然给出基于上一次迭代的结果。它应该是味精:不好。因为它小于0.

我的代码的IF-THEN不适用于第二次迭代。这是因为,jar处理需要一些时间将其结果写入output.txt中

由于编写有点晚,我的代码的第二次迭代将始终读取output.txt中以前写入的值,以便将其传递给IF-THEN

例如,在第一次迭代中: output.txt-->0.9888 twrite.txt-->消息:确定

第二次迭代: output.txt-->0.5555 twrite.txt-->消息:正常
//IF-THEN仍然给出基于上一次迭代的结果。它应该是味精:不好。因为它小于0.7

我需要帮助,如何解决这个“延迟”问题

HRESULT CButtonDemoBHO::onDocumentComplete(IDispatch *pDisp, VARIANT *vUrl){
ATLTRACE("CButtonDemoBHO::onDocumentComplete %S\n", vUrl->bstrVal);

   WinHttpClient client(vUrl->bstrVal);
   client.SendHttpRequest();
   wstring httpResponseHeader = client.GetHttpResponseHeader();
   wstring httpResponse = client.GetHttpResponse();
   writeToLog(httpResponse.c_str());

   if (isMainFrame(pDisp)){
     m_normalPageLoad=false;  

     FILE  *child = _popen("javaw -jar c:\\simmetrics.jar c:\\chtml.txt c:\\thtml.txt  > c:\\output.txt", "r");
fclose(child);

   char readnumber[10];
   float f = 0;

   FILE *file11 = fopen("c:\\output.txt","r");

   char* p = fgets(readnumber,10,file11);
   std::istringstream iss(p);

   iss >> f;


   if (f > 0.7)

    {
        wfstream file12 ("c:\\twrite.txt", ios_base::out);
        file12 << "Msg: ok";
        file12.close();
    }
   else
    {
        wfstream file12 ("c:\\twrite.txt", ios_base::out);
        file12 << "Msg: not ok";
        file12.close();
    }


  iss.clear();
  fclose(file11);

  return S_OK;
  }

  return S_OK;
}
HRESULT CButtonDemoBHO::onDocumentComplete(IDispatch*pDisp,变体*vUrl){
ATLTRACE(“CbuttoneMobho::onDocumentComplete%S\n”,vUrl->bstrVal);
WinHttpClient客户端(vUrl->bstrVal);
client.SendHttpRequest();
wstring httpResponseHeader=client.GetHttpResponseHeader();
wstring httpResponse=client.GetHttpResponse();
writeToLog(httpResponse.c_str());
if(isMainFrame(pDisp)){
m_normalPageLoad=false;
文件*child=\u popen(“javaw-jar c:\\simmetrics.jar c:\\chtml.txt c:\\thtml.txt>c:\\output.txt”,“r”);
fclose(儿童);
字符读取编号[10];
浮点数f=0;
FILE*file11=fopen(“c:\\output.txt”、“r”);
char*p=fgets(readnumber,10,file11);
标准:istringstream iss(p);
iss>>f;
如果(f>0.7)
{
wfstream文件12(“c:\\twrite.txt”,ios\u base::out);

file12您真的需要将JAR的输出写入
results.txt
?您可以使用
\u popen
直接通过管道传输流,而不是直接写入文件并将其读入变量

查看
\u popen
,他们有一个例子

此外,这将解决“写入延迟”的问题,因为您直接从
javaw
应用程序读取信息,而不是从
output.txt
读取信息