如何解决编译时出现的fatal error C1004: unexpected end of file found问题

来源:百度知道 编辑:UC知道 时间:2024/05/21 11:43:39
#include "pcap.h"
struct ether_header
{
u_int8_t ether_dhost[6];
u_int8_t ether_shost[6];
u_int16_t ether_type;

};
void ethernet_protocol_packet_callback(u_char*argument_wentaoliu,const struct
pcap_pkthdr*packet_header,const u_char*packet_content)
{
u_short ethernet_type;
struct ether_header*ethernet_protocol;
u_char*mac_string;
static int packet_number=1;
printf("--------------------------------------\n");
printf("捕获第 %d个以太网数据包\n",packet_number);
printf("数据包长度:\n");
printf("%d\n",packet_header->len);
printf("---------以太网协议---------\n");
ethernet_protocol=(struct ether_header*)packet_content;
printf("以太网类型:\n");
ethernet_type=ntohs(ethernet_protocol->ether_type);
printf("%04x\n",ethernet_type);
switch(ethernet_type)
{

编译的时候要加条件知道吗 -lpcap
*(mac_string+2),*(mac_string+3)' 这行的符号。有两处。

别的错误 就没发现了。
还有就是你可以再linux下编辑一下看看 错误到底是什么。它都有提示的。我现在在windows下看得

现在这个代码我在linux下调试通过了

#include <pcap.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <string.h>
struct ether_header
{
u_int8_t ether_dhost[6];
u_int8_t ether_shost[6];
u_int16_t ether_type;

};
void ethernet_protocol_packet_callback(u_char*argument_wentaoliu,const struct
pcap_pkthdr*packet_header,const u_char*packet_content)
{
u_short ethernet_type;
struct ether_header*ethernet_protocol;
u_char*mac_string;
static int packet_number=1;
printf("--------------------------------------\n");
printf("捕获第 %d个以太网数据包\n",packet_number);
printf("数据包长度:\n");
printf("%d\n",packet_header->len);
printf("---------以太网