C语言提问求修改

来源:百度知道 编辑:UC知道 时间:2024/06/30 17:36:50
#define TCP 1
#define UDP 2
#define IPLENS 20
#define KEYLOADLENS 100

#include <stdio.h>

struct current//数据流量
{
char ch_SourIP[IPLENS]; //源IP
char ch_DestIP[IPLENS]; //目地IP
unsigned short int sin_SourPort; //源端口
unsigned short int sin_DestPort; //目地端口
unsigned short int PortocolType; //协议类型
int KeyLoad[KEYLOADLENS]; //关键净负荷
};

/****************常见端口陪陪识别引擎************************************************************/
port_distinguish(int sin_TestPort)
{
switch(sin_TestPort);
{
case 20: break;
case 81: break;
case 80: break;
default : printf("default");//SPort_distinguish(TestPort);
}
}
/**************************特殊端口识别程序******************************************************/
/*SPort_distinguish(TestPort)
{
switch(TestPort)
}
*/

/**

错误有两处,3点
port_distinguish(int sin_TestPort)
{
switch(sin_TestPort); ////////此处不应加分号
{
case 20: break;
case 81: break;
case 80: break;
default : printf("default");//SPort_distinguish(TestPort);
}
}

main()
{
struct current Cur_Data[10]={"222.18.182.12","210.41.224.33",80,53,TCP};
port_distinguish((unsigned short int) Cur_Data->sin_SourPort); ////这个应该是强制类型转换应加括号,并且current也应该去掉,前面已经定义过了
}

1、
/****************常见端口陪陪识别引擎**********/
port_distinguish(int sin_TestPort)
{
switch(sin_TestPort);

多了一个分号。
switch后不能有分号。

2、
port_distinguish(int sin_TestPort)无返回值应该显示定义为void
void port_distinguish(int sin_TestPort)

3、
port_distinguish(unsigned short int current Cur_Data->sin_SourPort);
函数调用,传进去实参就行了。不就应该是:
port_distinguish(Cur_Data->sin_SourPort);

4、c中默认返回值类型为int,所以main无返