Article View: comp.lang.java.api
Article #8Re: Strange I/O behavior
From: Eric Albert
Date: Thu, 07 Dec 2000 00:00
Date: Thu, 07 Dec 2000 00:00
21 lines
1390 bytes
1390 bytes
In article <mwron-0712001211280001@c243286-a.bcreek1.mi.home.com>,
mwron@metrowerks.com (MWRon) wrote:
> Try
>
> while (((char)ch) != ('\n' || '\r') && ch > -1)
>
> Note I'm a C programer not Java so I'd appreciate any corrections on my
> assumptions.
Your code won't do the right thing in C and won't compile in Java, but
it's the right idea. :) I think this is what you meant:
while((char) ch != '\n' && (char) ch != '\r' && ch > -1)
In C, the ('\n' || '\r') will evaluate to 1, so you'd get while(ch != 1
&& ch > -1), which ain't quite what you're expecting. :)
-Eric
--
Eric Albert ejalbert@stanford.edu
http://www.stanford.edu/~ejalbert/
Technical Details
Message-ID:
<ejalbert-B35454.10542507122000@nntp.stanford.edu>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<mtobin-99A222.22175206122000@news.earthlink.net> <mwron-0712001211280001@c243286-a.bcreek1.mi.home.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10bcce,139b3b33219ebf5 X-Google-Attributes: gid10bcce,public X-Google-Thread: f635e,139b3b33219ebf5 X-Google-Attributes: gidf635e,public X-Google-Thread: fecd1,139b3b33219ebf5 X-Google-Attributes: gidfecd1,public From: Eric Albert <ejalbert@stanford.edu> Subject: Re: Strange I/O behavior Date: 2000/12/07 Message-ID: <ejalbert-B35454.10542507122000@nntp.stanford.edu> X-Deja-AN: 702265101 References: <mtobin-99A222.22175206122000@news.earthlink.net> <mwron-0712001211280001@c243286-a.bcreek1.mi.home.com> User-Agent: MT-NewsWatcher/3.1b2 (PPC) Newsgroups: comp.lang.java.api,comp.sys.mac.programmer.codewarrior,codewarrior.mac