<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2873" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2>Why are you trying to use the argv variable?</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>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.</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>You should use your own char array, like</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>int main()</FONT></DIV>
<DIV><FONT size=2>{</FONT></DIV>
<DIV><FONT size=2> char text[512];</FONT></DIV>
<DIV><FONT size=2> fgets(text, 512, stdin);</FONT></DIV>
<DIV><FONT size=2> ....</FONT></DIV>
<DIV><FONT size=2>}</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>The reason why </FONT><FONT size=2>"*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).</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>Have a nice day</FONT></DIV>
<DIV><FONT size=2>GV</FONT></DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=benjamin.amaudric@hotmail.fr
href="mailto:benjamin.amaudric@hotmail.fr">Benjamin Amaudric</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=winpcap-users@winpcap.org
href="mailto:winpcap-users@winpcap.org">winpcap-users@winpcap.org</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Monday, May 15, 2006 1:24 AM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> [Winpcap-users]
Readfile_ex</DIV>
<DIV><FONT size=2></FONT><FONT size=2></FONT><FONT size=2></FONT><BR></DIV>
<DIV>
<DIV class=RTE>Hi,</DIV>
<DIV class=RTE><FONT size=2></FONT> </DIV>
<DIV class=RTE>I'm student and I'm starting use differents functions of
WinPcap. </DIV>
<DIV class=RTE>I've a problem when I try to open a pcap file like it's show in
Readfile_ex.</DIV>
<DIV class=RTE><FONT size=2></FONT> </DIV>
<DIV class=RTE>It is possible to choose which file we want to open? And the
directory where the file is?</DIV>
<DIV class=RTE><FONT size=2></FONT> </DIV>
<DIV class=RTE>I try to use this: but it doesnt't work!</DIV>
<DIV class=RTE><FONT size=2></FONT> </DIV>
<DIV class=RTE><FONT size=2></FONT> </DIV>
<DIV class=RTE><STRONG>printf("Which file would you like to
open?\n");<BR>fgets(reinterpret_cast<char *> (* argv), 100, stdin);
</STRONG></DIV>
<DIV class=RTE><STRONG></STRONG> </DIV>
<DIV class=RTE><STRONG> /* Open the capture file */<BR> if ((fp=
pcap_open_offline(reinterpret_cast<const char
*>(*argv), <BR>
errbuf // error
buffer<BR> )) ==
NULL)<BR> {<BR> fprintf(stderr,"\nUnable to open the file
%s.\n", *argv);<BR> return -1;<BR> }</STRONG></DIV>
<DIV class=RTE><FONT size=2></FONT> </DIV>
<DIV class=RTE><FONT size=2></FONT> </DIV>
<DIV class=RTE>However, if I do this, it works!!</DIV>
<DIV class=RTE><FONT size=2></FONT> </DIV>
<DIV class=RTE><STRONG>*argv ="save";</STRONG></DIV>
<DIV class=RTE><FONT size=2></FONT> </DIV>
<DIV class=RTE>
<DIV class=RTE><STRONG> /* Open the capture file */<BR> if ((fp=
pcap_open_offline(reinterpret_cast<const char
*>(*argv), <BR>
errbuf // error
buffer<BR> )) ==
NULL)<BR> {<BR> fprintf(stderr,"\nUnable to open the file
%s.\n", *argv);<BR> return -1;<BR> }</STRONG></DIV></DIV>
<DIV class=RTE><FONT size=2></FONT> </DIV>
<DIV class=RTE><FONT size=2></FONT> </DIV>
<DIV class=RTE>Maybe someone tried to do this already!!!</DIV>
<DIV class=RTE><FONT size=2></FONT> </DIV>
<DIV class=RTE>Thanks you§</DIV></DIV><BR clear=all>
<HR>
MSN Hotmail <A href="http://g.msn.com/8HMAFRFR/2746??PS=47575" target=_top>:
créez votre adresse e-mail gratuite & à vie !</A>
<P>
<HR>
<P></P>_______________________________________________<BR>Winpcap-users
mailing
list<BR>Winpcap-users@winpcap.org<BR>https://www.winpcap.org/mailman/listinfo/winpcap-users<BR></BLOCKQUOTE></BODY></HTML>