[Winpcap-users] Readfile_ex
Gianluca Varenni
gianluca.varenni at cacetech.com
Mon May 15 16:10:31 GMT 2006
Why are you trying to use the argv variable?
That is a pointer to an array of (read-only) strings passed as arguments to the main of you app, hence it should NOT be used as an argument to fgets.
You should use your own char array, like
int main()
{
char text[512];
fgets(text, 512, stdin);
....
}
The reason why "*argv = "save"; " works is probably because you are assigning a constant string to *argv, so you are not overwriting memory (but this is just speculating over buggy code).
Have a nice day
GV
----- Original Message -----
From: Benjamin Amaudric
To: winpcap-users at winpcap.org
Sent: Monday, May 15, 2006 1:24 AM
Subject: [Winpcap-users] Readfile_ex
Hi,
I'm student and I'm starting use differents functions of WinPcap.
I've a problem when I try to open a pcap file like it's show in Readfile_ex.
It is possible to choose which file we want to open? And the directory where the file is?
I try to use this: but it doesnt't work!
printf("Which file would you like to open?\n");
fgets(reinterpret_cast<char *> (* argv), 100, stdin);
/* Open the capture file */
if ((fp= pcap_open_offline(reinterpret_cast<const char *>(*argv),
errbuf // error buffer
)) == NULL)
{
fprintf(stderr,"\nUnable to open the file %s.\n", *argv);
return -1;
}
However, if I do this, it works!!
*argv ="save";
/* Open the capture file */
if ((fp= pcap_open_offline(reinterpret_cast<const char *>(*argv),
errbuf // error buffer
)) == NULL)
{
fprintf(stderr,"\nUnable to open the file %s.\n", *argv);
return -1;
}
Maybe someone tried to do this already!!!
Thanks you§
------------------------------------------------------------------------------
MSN Hotmail : créez votre adresse e-mail gratuite & à vie !
------------------------------------------------------------------------------
_______________________________________________
Winpcap-users mailing list
Winpcap-users at winpcap.org
https://www.winpcap.org/mailman/listinfo/winpcap-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.winpcap.org/pipermail/winpcap-users/attachments/20060515/1497a5c5/attachment.htm
More information about the Winpcap-users
mailing list