Re: (1) Multiple Stdio.h files - which one? (2) fgets()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 28 December 2011 20:23, Matthew D. Gutchess wrote:
>    (2) In the sample program below, using fgets() instead of gets() results in a "No such file or directory error", but the program would open and display the file when gets() was used.  Is this because fgets() appends "/0" to the entered file name and this must be stripped off?

No, the '\0' added by fgets is necessary.

Change the line that prints out the filename like so and you should
see the problem:

       printf("You entered '%s' ", pathname);

If that doesn't help, read the man page for fgets which is quite clear
about its behaviour.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux