Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C > Re: extra chara...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 8 of 9 Topic 25476 of 28006
Post > Topic >>

Re: extra character when writing file

by "Bartc" <bc@[EMAIL PROTECTED] > Apr 10, 2008 at 10:26 AM

"Willem" <willem@[EMAIL PROTECTED]
> wrote in message 
news:slrnfvrn2k.a3u.willem@[EMAIL PROTECTED]
> Bartc wrote:
> ) I also made my own feof() which works the way you and I might expect, 
> but
> ) that involves a lot of bad code using fseeks, ftells and assorted
> ) assumptions, so I won't post it here!
>
> What's wrong with using getc() and ungetc() ?

Well, I never thought of using ungetc(). I've just tried a simplified 
version of your code as:

/* Return 1 (true) if positioned at EOF, or on error */
/* Return 0 (false) otherwise */

int pascal_eof(FILE *stream) {
   int c = getc(stream);
   if (c == EOF) return 1;
   if (ungetc(c,stream) == EOF) return 1;
   return 0;
 }

-- 
Bart
 




 9 Posts in Topic:
extra character when writing file
Jim <jim.moneytime@[EM  2008-04-09 20:33:38 
Re: extra character when writing file
Richard Heathfield <rj  2008-04-10 04:03:44 
Re: extra character when writing file
Peter Nilsson <airia@[  2008-04-09 21:12:29 
Re: extra character when writing file
Jim <jim.moneytime@[EM  2008-04-09 21:15:08 
Re: extra character when writing file
Richard Heathfield <rj  2008-04-10 04:30:08 
Re: extra character when writing file
"Bartc" <bc@  2008-04-10 09:09:17 
Re: extra character when writing file
Willem <willem@[EMAIL   2008-04-10 09:22:28 
Re: extra character when writing file
"Bartc" <bc@  2008-04-10 10:26:08 
Re: extra character when writing file
CBFalconer <cbfalconer  2008-04-10 10:36:36 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Nov 21 11:09:51 CST 2008.