J
jeniffer
[$] gcc -c test.c
[$] gcc -o test test.c
[$] ./test
i=6
0 14 22 42 48 e6
014224248ffffffe6
ea = [$]
I am not able to obtain the value of ea in main ....plz tell me how to
correct the problem
#include<stdio.h>
int main()
{
int i;
i=Set_Entry();
return 0;
}
int Set_Entry()
{
char eaddr[]="0:14:22:42:48:e6";
unsigned char*ea;
char sa_data[14];
ea=(char*)sa_data;
if(ether_aton(eaddr,ea))
{
printf("\nreturning 1");
return (1);
}
printf("ea = %s",ea);
return 0;
}
ether_aton(a, n)
char *a;
char *n;
{
int i, o[6];
i = sscanf(a, "%x:%x:%x:%x:%x:%x", &o[0], &o[1], &o[2],
&o[3], &o[4], &o[5]);
printf("\n i=%d\n",i);
printf("%x %x %x %x %x %x",o[0],o[1],o[2],o[3],o[4],o[5]);
if (i != 6) {
perror("arp: invalid Ethernet address");
return (1);
}
for (i=0; i<6; i++)
n=o;
printf("\n");
for(i=0;i<6;i++)
printf("%x",n);
printf("\n");
return (0);
}
[$] gcc -o test test.c
[$] ./test
i=6
0 14 22 42 48 e6
014224248ffffffe6
ea = [$]
I am not able to obtain the value of ea in main ....plz tell me how to
correct the problem
#include<stdio.h>
int main()
{
int i;
i=Set_Entry();
return 0;
}
int Set_Entry()
{
char eaddr[]="0:14:22:42:48:e6";
unsigned char*ea;
char sa_data[14];
ea=(char*)sa_data;
if(ether_aton(eaddr,ea))
{
printf("\nreturning 1");
return (1);
}
printf("ea = %s",ea);
return 0;
}
ether_aton(a, n)
char *a;
char *n;
{
int i, o[6];
i = sscanf(a, "%x:%x:%x:%x:%x:%x", &o[0], &o[1], &o[2],
&o[3], &o[4], &o[5]);
printf("\n i=%d\n",i);
printf("%x %x %x %x %x %x",o[0],o[1],o[2],o[3],o[4],o[5]);
if (i != 6) {
perror("arp: invalid Ethernet address");
return (1);
}
for (i=0; i<6; i++)
n=o;
printf("\n");
for(i=0;i<6;i++)
printf("%x",n);
printf("\n");
return (0);
}