关于C中的参数类型问题
各位好:
我现在有一个问题,想向大家请教下:
我从网上下载了uIP0.9这个协议栈,已移植成功,可以正常通信,我现在正在测试它的SMTP的示例程序,但发现有几个函数的参数我不知道怎样配置,望各位兄弟帮下忙,在此先谢谢了!
它的smtp示例有一个这样的函数:
相关变量:
typedef unsigned short u16_t;
static char *localhostname;
static u16_t smtpserver[2];
smtp_configure函数的注释:
/*-----------------------------------------------*/
/**
* Specificy an SMTP server and hostname.
*
* This function is used to configure the SMTP module with an SMTP
* server and the hostname of the host.
*
* \param lhostname The hostname of the uIP host.
*
* \param server A pointer to a 4-byte array representing the IP
* address of the SMTP server to be configured.
*/
/*-----------------------------------------------*/
//smtp_configure函数体
void smtp_configure(char *lhostname, u16_t *server)
{
localhostname = lhostname;
smtpserver[0] = server[0];
smtpserver[1] = server[1];
}
以上函数中的第一个参数我知道是一个本地主机名的字符数组,但第二个参数我不知道该怎样配置,第二个参数按照uIP0.9的用户手册说是smtp服务器的IP地址,但是为什么会有smtpserver[0] = server[0]; smtpserver[1] = server[1];
在实际应用中我该怎样给这个函数赋实参呢?
[解决办法]
u16_t *server:是一个u16_t的数组,里面存的smtp server的ip地址,由于ip地址长度是4个字节32bit,因此server[0]存的是ip地址前16bit,server[1]存的是ip地址后16bit。