#include <ace/ACE.h>
#include <ace/Log_Msg.h>
#include <ace/Log_Msg_Callback.h>
#include <ace/Log_Record.h>
#include <iostream>
using namespace std;
class LogCall : public ACE_Log_Msg_Callback
{
public:
LogCall(){}
~LogCall(){}
virtual void log (ACE_Log_Record &log_record)
{
cout<<"这是回调之后打印出来的内容:"<<endl;
cout<<log_record.msg_data()<<endl;
}
};
int ACE_TMAIN(int, ACE_TCHAR *[])
{
LogCall *pCall=new LogCall();
ACE_LOG_MSG->set_flags(ACE_Log_Msg::MSG_CALLBACK);
//ACE_LOG_MSG->clr_flags(ACE_Log_Msg::STDERR);
ACE_LOG_MSG->msg_callback(pCall);
ACE_DEBUG((LM_ERROR,ACE_TEXT(" %D大家好啊\n")));
getchar();
return 0;
}
FILE *stream;
char list[30];
int i, numread, numwritten;
/* Open file in text mode: */
if( (stream = fopen( "fread.out", "w+t" )) != NULL )
{
for ( i = 0; i < 25; i++ )
list[i] = (char)('z' - i);
/* Write 25 characters to stream */
numwritten = fwrite( list, sizeof( char ), 25, stream );
printf( "Wrote %d items\n", numwritten );
fclose( stream );
}
else
printf( "Problem opening the file\n" );
if( (stream = fopen( "fread.out", "r+t" )) != NULL )
{
/* Attempt to read in 25 characters */
numread = fread( list, sizeof( char ), 25, stream );
printf( "Number of items read = %d\n", numread );
printf( "Contents of buffer = %.25s\n", list );
fclose( stream );
}
else
printf( "File could not be opened\n" );