Eclipse Debug运行和同一程序的控制台运行给出不同的输出

时间:2014-09-19 09:21:39

标签: c++ linux eclipse cout eclipse-cdt

所以这是关于我修复的旧问题。

现在的问题是,当我运行我的程序时(代码如下)......

#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
}

eclipse调试模式的运行putput和控制台(linux)中的运行putput是不同的。

eclipse在两个eclipse控制台中运行并重定向到终端。

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

终端运行(./main)

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

造成这种情况的原因是什么?

0 个答案:

没有答案
相关问题