Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > EOF question

Reply
Thread Tools

EOF question

 
 
CBFalconer
Guest
Posts: n/a
 
      08-11-2004
Kenneth Brody wrote:
> >

.... snip ...
>
> It could be a bug in Windows and/or the C runtime.
>
> Change the printf() line to read:
>
> printf("aefore newline\nafter newline %ld\n",nc);
>
> On Windows 98, with MSVC 6.0a (compiler version 12.00.816 typing
> "foobar" newline Ctrl-Z newline, I get:
>
> foobar
> after newline 7
>
> Note that everything in the printf() prior to the newline is gone.
>
> On Windows XP:
>
> foobar
> ^Z
> before newline
> after newline 7
>
> And the program has not yet exited. I need to press Enter one
> more time to get the program to exit.


It's not W98 FE. Under that, and DJGPP 2.03, gcc 3.3.1:

[1] c:\c\junk>gcc junk.c

[1] c:\c\junk>a
Bloody nonsense
^Z
16

[1] c:\c\junk>type junk.c
#include <stdio.h>

int main(void)
{
long nc;

nc = 0;
while (getchar() != EOF) ++nc;
printf("%ld\n", nc);
return 0;
}

--
"Churchill and Bush can both be considered wartime leaders, just
as Secretariat and Mr Ed were both horses." - James Rhodes.
"A man who is right every time is not likely to do very much."
- Francis Crick, co-discover of DNA


 
Reply With Quote
 
 
 
 
newby2c
Guest
Posts: n/a
 
      08-12-2004
"Kenneth Brody" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> It could be a bug in Windows and/or the C runtime.
>
> Change the printf() line to read:
>
> printf("aefore newline\nafter newline %ld\n",nc);
>
> On Windows 98, with MSVC 6.0a (compiler version 12.00.816 typing
> "foobar" newline Ctrl-Z newline, I get:
>
> foobar
> after newline 7
>
> Note that everything in the printf() prior to the newline is gone.
>
> On Windows XP:
>
> foobar
> ^Z
> before newline
> after newline 7
>
> And the program has not yet exited. I need to press Enter one more time
> to get the program to exit.


I get the same results as you except the program terminates after <ctrl-z>.

newby2c


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Jan Burse Java 67 03-14-2012 12:21 AM
ifstream eof not reporting eof? SpreadTooThin C++ 10 06-15-2007 08:49 AM
if EOF = -1, can't a valid character == EOF and cause problems? Kobu C Programming 10 03-04-2005 10:40 PM
A question about EOF SL_McManus Perl 1 12-04-2003 01:50 AM
Newbie Question: EOF in MS Visual Studio 2003? entropy123 C Programming 6 07-03-2003 06:25 PM



Advertisments