返回值的函数 [英] Function To Return A Value

查看:103
本文介绍了返回值的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取此函数以返回值1或0,以便可以在其他地方引用它?谢谢.

How do I get this function to return a value of 1 or 0 so that I can reference it elsewhere? Thank you.

void end_packet(char *_packet)
{
TCPHEADER *tcp_header = (TCPHEADER *)_packet;
BYTE flags = ( ntohs(tcp_header->info_ctrl) & 0x003F );
int EP;
	if ( flags & 0x01 && flags & 0x10 )
		{
		EP = 1; //End
		}
	else
	{
		EP = 0; //Not End
	}
}

推荐答案

请参阅我对问题的评论.

您怎么能问这个问题并声明一个void函数?输入一个返回类型,例如byte并返回EP-如果是这种类型.更好的是,引入值为0和1的enum类型并返回它.那是你的问题吗?

—SA
Please see my comment to the question.

How can you ask this question and declare a void function?! Make a return type, say, byte and return EP — if this type. Better yet, introduce enum type with values of 0 and 1 and return it. Is that was your problem?

—SA


您可能想了解如何使用C或C ++语言的函数,请参见教程.

这样,与尝试仅通过示例弄清该语言的工作方式相比,将需要更多的时间来理解C ++编程的原理.区别将与考古学家用来解析未知语言而不是使用词典来解析未知语言的时间相同!
You might want to read up on how to use functions in the C or C++ language Check out Functions at www.cplusplus.com. Or better yet, go for the Tutorial there.

It will take you a lot less time understanding the principles of C++ programming that way than trying to figure out the workings of the language by example alone. the difference will be about the same as the time an archeologist would take to decipher an unknown language as opposed to one using a dictionary!


这篇关于返回值的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆