将数据输入到函数
她我通过printf输入数据
printf("enter the src ipaddress \n");
scanf("%s",buff);
inet_aton(buff, &(delete_node.ip.ip_src));
printf("enter the dst ip address\n");
scanf("%s",buff);
inet_aton(buff, &(delete_node.ip.ip_dst));
printf("enter the source port\n");
scanf("%d",port);
delete_node.protocol.proto.uh_sport = ntohs(port);
printf("enter the destination port\n");
scanf("%d",port);
delete_node.protocol.proto.uh_dport = ntohs(port);
我想写一个输入上面参数的函数怎么写?在这里,我将数据输入到我想要存储的位置。如delete_node.ip.ip_src等,其中delete_node是一个结构体。如何编写一个函数来执行与上述 printf 语句相同的任务
her i am inputting the data through printf
printf("enter the src ipaddress \n");
scanf("%s",buff);
inet_aton(buff, &(delete_node.ip.ip_src));
printf("enter the dst ip address\n");
scanf("%s",buff);
inet_aton(buff, &(delete_node.ip.ip_dst));
printf("enter the source port\n");
scanf("%d",port);
delete_node.protocol.proto.uh_sport = ntohs(port);
printf("enter the destination port\n");
scanf("%d",port);
delete_node.protocol.proto.uh_dport = ntohs(port);
i want to write a function which inputs the above parameter how to write it ? here i am inputting it the data to place i want to store it. like delete_node.ip.ip_src and so on, where delete_node is a structure. how to write a function which performs the same task that of the above printf statements
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
让函数接收指向结构的指针并在内部使用它:
Have the function receive a pointer to the struct and use it inside: