本文介绍了功能未打印到日志文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我有一个在程序的main()中运行的日志文件.我也有一个在main()中调用的函数.该功能可以正常工作并打印到控制台,但是日志文件也可以正常工作.函数的返回值不会打印到日志文件中,我是否需要为此做些事情?该功能.

I have a log file that runs in the main() of the program. I also have a function that is called within the main(). The fuction works fine and prints to console, the log file works fine as well, however; the return values from the fuction don''t print to the log file, is there something specil that I have to do for this to happen? The function.

void decode_tcp(char *_packet)
{
	TCPHEADER *tcp_header = (TCPHEADER *)_packet;
    BYTE flags = ( ntohs(tcp_header->info_ctrl) & 0x003F );
	if ( flags & 0x01 ) // FIN
		printf("\n   FIN " );
		myfile << "\n   FIN " ;
	if ( flags & 0x02 ) // SYN
		printf("\n   SYN " );
		myfile << "\n   SYN " ;
	if ( flags & 0x04 ) // RST
		printf("\n   RST " );
		myfile << "\n   RST " ;
	if ( flags & 0x08 ) // PSH
		printf("\n   PSH " );
		myfile << "\n   PSH " ;
	if ( flags & 0x10 ) // ACK
		printf("\n   ACK " );
		myfile << "\n   ACK " ;
	if ( flags & 0x20 ); // URG
		printf("\n   URG " );
		myfile << "\n   URG " ;
		printf("\n   Sequence Number  : %lu\n", ntohl(tcp_header->seq_number));
		myfile << "\n   Sequence Number  :"<< ntohl(tcp_header->seq_number);
	}

推荐答案


if ( flags & 0x01 ) // FIN
    printf("\n   FIN " );
myfile << "\n   FIN " ;


压痕得到纠正后?
我是否可以建议您始终使用大括号将ifdowhile等目标括起来.


once the indentation has been corrected?
May I suggest you always use braces to bracket the target of if, do, while etc.



这篇关于功能未打印到日志文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 08:58