I'm a newbie with C language and I'm trying to write an Idle port monitor application for ethernet networks, the application measures broadcast traffic by protocol and generates a text file report, however the output it prints to the file is different from what is expected for example in line 174 of the code as shown below it prints out the expected value arp1_source
arp1_source = source;
fprintf(stdout,"arp1->source is %s\n",arp1_source);
but when it prints out the content of the same variable in line 1365, it prints out a different mac address
fprintf(stdout ," %s %d.%d.%d.%d %d %d\n",
arp1_source,
arp1_ip_source[0],
arp1_ip_source[1],
arp1_ip_source[2],
arp1_ip_source[3],
arp1_total,
arp1);
I'm at a loss as to why this is happening,I have no idea of what I'm doing wrong please help,my code is below(although it quite long and I can send the full code if required ) thanks.
I have defined the variables but when I'm performing a live capture of packets, the value inside arp1_source printed out in the first line is different from what is written into the text file after the capture is complete that is in the first line it may print out
"arp1-source is 0e:32:64:89:20:5e"
and when it is to print out the mac address stored inside arp1_source to the text file as shown in the second code, it prints out a wrong mac address, seems like original mac address is overwritten by another one,I declared the char string to store the mac address with a const keyword.