Re: Fgets is not working on linux/gcc3.2.1

Michael Schwendt <[email protected]>
Newsgroups gmane.linux.redhat.devel
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thu, 10 Apr 2003 18:03:02 +0530, Ajay Bansal wrote:

> Problem was not that I _have_ to read a file somehow. Problem was.. How
> do read using fgets.  & why it bbehaves differently on Solaris/Linux
> with same compiler. 
> 
> If I open the file with "a+", the on Solaris file pointer is at the
> beginning of the file whereas on Linux it is at the end of the file. Why
> is this difference???

'a' = append, but appending makes sense only at the end of a file.
'a' without positioning the file pointer at the end of the file
would be like 'w' (writing) and would NOT append, but overwrite
(truncate) the file. 'a+' is like 'a' but also gives 'r'
read-access.

What does the manual on Solaris say about 'a' and 'a+'?

> And if some code is already written using fgets on solaris, this
> difference makes it non-portable!!!!!

Remains to be seen whether the API is non-portable or whether the
source code is.

- -- 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE+lXYi0iMVcrivHFQRAsznAJ9hhbIXeATOMZMriPdp2ys0O31dwwCfTZmt
g2pN3+xnSTHlZy/59bHmAQI=
=Xty9
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.