[OCLUG-devel] fopen doesn't like my path

Michael Elkins michael.elkins at gmail.com
Sun Nov 20 18:28:33 PST 2005


You'll likely need to post the code snippet your using in order for us
to determine what the exact issue is.  Nothing in your description
seems incorrect.

Michael

On 11/20/05, Doug Jolley <ddjolley at gmail.com> wrote:
> I am using fopen to open two different files.  In the first case (which
> works just fine), I simply define the path to the file as 'char
> path2file[]="/path/to/file"'.  I then use path2file as the first argument to
> fopen.  In the second case (which doesn't work so well), I extract the path
> to the file from colon-delimited data contained in a string using strtok.
> IOW, I use the  following 'path=strtok(NULL,":")'.  I use NULL here because
> I have previously extracted other tokens and the path is the next token to
> be extracted.  I inserted a printf statement to print 'path' and it does in
> fact point to the correct data.  However, when I put 'path' as the first
> argument to fopen, I get a segmentation fault.  If I replace the 'path'
> argument to fopen with the actual correct path to the file (by just
> including the actual string enclosed in double quotes), it works just fine.
> So, it certainly appears that fopen doesn't like my path pointer which was
> derived from strtok; but, I have absolutely no idea why.  Can anyone help me
> out?  Thanks for any input.
>
>          ... doug
>
> _______________________________________________
> OCLUG-devel mailing list -- OCLUG-devel at oclug.org
> http://mailman.oclug.org/mailman/listinfo/oclug-devel
>
>
>


More information about the OCLUG-devel mailing list