Eclipse Debug run and console run of the same program give different outputs

旧城冷巷雨未停 提交于 2019-12-23 05:44:12

问题


So this is in reference to my older question which I fixed.

Now the issue is that when I run my program (code as follows)...

#include <stdio.h>
#include <memory.h>

#include <string>
#include <iostream>

using namespace std;

#include "timesync.h"

FILE * CTimeSync::pipe = NULL;

int CTimeSync::TimeSyncCheck()
{
    char szPipeBuffer [200];
    string strPipeOutput;

    memset( szPipeBuffer, 0, sizeof(szPipeBuffer) );

    CTimeSync::pipe = popen( "ntpq -np", "r" );
    if ( CTimeSync::pipe )
    {
        while ( !feof( CTimeSync::pipe ) )
        {
            if ( fgets( szPipeBuffer, 200, CTimeSync::pipe ) != NULL )
            {
//              memset( szPipeBuffer, 0, sizeof(szPipeBuffer) );
                strPipeOutput.append(szPipeBuffer);
            }
        }

        pclose(CTimeSync::pipe);
    }

    cout << strPipeOutput;
    cout << "abc\npqr\nxyz\n123" << endl; //test string
    return 1; //ERROR
}

the run putputs for eclipse debug mode and that in the console (linux) are different.

eclipse run in both eclipse console and redirected to terminal.

     remote           refid          st   t  when poll reach    delay    offset  jitter
abc
pqr
xyz
123

Terminal run (./main)

     remote           refid          st   t  when poll reach    delay    offset  jitter
=======================================================================================
*10.92.1.200       LOCAL(1) ...
abc
pqr
xyz
123

what is causing this?

来源:https://stackoverflow.com/questions/25930546/eclipse-debug-run-and-console-run-of-the-same-program-give-different-outputs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!