I
Ike Naar
while (((c = fgetc(fp)) != EOF) || ((d = fgetc(fq)) != EOF)) {
Why are you using ``||'' here? Wouldn't ``&&'' make more sense?
while (((c = fgetc(fp)) != EOF) || ((d = fgetc(fq)) != EOF)) {
fclose(fp);
return 0;
}
// cc -Wall -Wextra cmp5.c -o cmp
$
I'm trying to get my head around what Alan Curry wrote about this:
"Octal 15 (ASCII CR) inserted before octal 12 (ASCII LF). Classical
text-mode FTP corruption."
Can someone say a few more words about what ftp may have done here?
I don't have an appropriate reference for fgetc and dinkumware has been
down.
What would I need to install to be able to man fgetc?
unsigned chars *are* what you should use to deal with binary data.
Your problem was that you were assigning the result of fgetc()
to an unsigned char object. Using a signed char or a plain char
would also have been wrong. fgetc() returns an int. Read your
documentation to see how that int value is generated.
I'm dropping comp.unix.shell from the cross-post.
What is the relationship between unsigned chars and ints? Both unsigned
and signed chars are subsets of ints, but why are unsigned chars the
representation of choice with binary data?
Uno said:What is the relationship between unsigned chars and ints? Both unsigned
and signed chars are subsets of ints, but why are unsigned chars the
representation of choice with binary data?
Because with signed char, there may be trap representations (binary
numbers that are not a valid signed char) in arbitrary binary data.
What is the relationship between unsigned chars and ints? Both unsigned
and signed chars are subsets of ints, but why are unsigned chars the
representation of choice with binary data?
[ snip ]
FTP was invented when dinosaurs roamed the Internet. The dinosaurs growled,
roared, and screeched ASCII, which was presented to the users on hardcopy
terminals - typewriters, basically.
That may be true of the dinosaurs that wanted to use this newfangled
file transfer protocol, but some of them (I'm thinking of the ones
made by IBM) mostly used another format, EBCDIC, for representing
character data. Just sayin' (after a rather long delay, for which
I apologize).
[If you're not old enough to have ever seen a typewriter, google up an image
of one now, or preferably a video of one in use.]
Good heavens -- are they really people who have never encountered a
typewriter at all? cue chorus of "I feel old", maybe ....
[ snip ]
The dinosaurs were a rowdy bunch, and they fought over how to properly store
text on non-typewriter-like media (like tapes and disks), but they were all
able to understand the typewriter-like ASCII-with-CRLF format. It was the
universal text representation. And it was incorporated into FTP as the
standard format for transmission of text files.
I just made a quick attempt to confirm my recollections about
whether the IBM 360/370 architecture included support for ASCII,
and -- it's kind of interesting that the Wikipedia articles say
that the 360 architecture included some features intended to
support ASCII (which had not been finalized), but that these were
not used, or not used widely, and the 370 architecture dropped at
least some of them. I wonder whether there was some consternation
when it became desirable to support FTP, it being ASCII-based.
(I'll leave the rest of this in because it's kind of charming.)
[If you're not old enough to have ever seen a typewriter, google up
an image of one now, or preferably a video of one in use.]
Good heavens -- are they really people who have never encountered a
typewriter at all? cue chorus of "I feel old", maybe ....
S/360 included a mode bit that altered the behavior of a handful of
instructions that were sensitive to the character set. This was mostly
the decimal instructions which encoded the sign in a nibble of the
least significant byte. For example, in unpacked ("display") form,
the decimal digits were 0xf0-0xf9 in EBCDIC. Thus +123 could be
encoded as 0xf1, 0xf2, 0xf3. A -123 would be encoded 0xf1, xf2, 0xd3.
(Several other values were valid for the sign as well.) So obviously
the instructions that converted between unpacked to packed format were
sensitive to the character set.
In any event, it was a modest behavior change to a few instructions.
And ASCII wasn't really cooked by the time IBM started development of
the OS's, so they ended up sticking with EBCDIC.
That mode bit was reused to enable "Extended Control" mode on the
S/370, which instead changed to format of the PSW and a few other
things (like some of the fixed location in low-core), that was a
prerequisite to enabling virtual memory. So ASCII mode went entirely
away with the S/370.
In the last ~15 years the ISA has grown a number of instructions
designed to ease the processing of ASCII data. Unicode too, as well
as instructions for converting to/from little-endian, and things like
C-style strings.
Thanks for filling in some of the details! That all sounds pretty
consistent with what the Wikipedia articles say, for what that's
worth. Interesting stuff -- though possibly more so to those of who
actually remember those days.
[If you're not old enough to have ever seen a typewriter, google up
an image of one now, or preferably a video of one in use.]
Good heavens -- are they really people who have never encountered a
typewriter at all? cue chorus of "I feel old", maybe ....
I'm in my early 30s, and the only _mechanical_ typewriter I've seen was
an antique originally owned by my grandfather, which my parents used in
college (long before I was born) and kept in storage for sentimental
reasons. I saw a few electronic typewriters in school, but they had all
disappeared by the time I graduated, and I can't recall having seen any
since then; kids just a few years younger than I likely wouldn't
remember them at all.
[If you're not old enough to have ever seen a typewriter, google up
an image of one now, or preferably a video of one in use.]
Good heavens -- are they really people who have never encountered a
typewriter at all? cue chorus of "I feel old", maybe ....
I'm in my early 30s, and the only _mechanical_ typewriter I've seen was
an antique originally owned by my grandfather, which my parents used in
college (long before I was born) and kept in storage for sentimental
reasons. I saw a few electronic typewriters in school, but they had all
disappeared by the time I graduated, and I can't recall having seen any
since then; kids just a few years younger than I likely wouldn't
remember them at all.
Probably typical .... At my CPOE the support staff say they still
want one typewriter, since it's the best tool for one or a few
form-filling-out jobs. I'd have thought maybe this would be true
at many offices, but maybe we're atypical!
[...]
I'm in my early 30s, and the only _mechanical_ typewriter I've seen was
an antique originally owned by my grandfather, which my parents used in
college (long before I was born) and kept in storage for sentimental
reasons. I saw a few electronic typewriters in school, but they had all
disappeared by the time I graduated, and I can't recall having seen any
since then; kids just a few years younger than I likely wouldn't
remember them at all.
Azazel said:[...]
I'm in my early 30s, and the only _mechanical_ typewriter I've seen
was an antique originally owned by my grandfather, which my parents
used in college (long before I was born) and kept in storage for
sentimental reasons. I saw a few electronic typewriters in school,
but they had all disappeared by the time I graduated, and I can't
recall having seen any since then; kids just a few years younger
than I likely wouldn't remember them at all.
Kids a few years younger still wouldn't even notice the
misuse of the nominative case.
OK, I'll bite. What misuse? "Kids just a few years younger than I
[am]" is correct.
Azazel said:On 6/21/2011 8:49 AM, Stephen Sprunk wrote:
kids just a few years younger than I likely wouldn't ...
Kids a few years younger still wouldn't even notice the
misuse of the nominative case.
OK, I'll bite. What misuse? "Kids just a few years younger than I
[am]" is correct.
<OT>
If the verb were there, then "I" would be unquestionably correct.
Without it, opinion is divided though not, I'd venture to say, 50/50.
The use of "I" forces "than" to be seen as a conjunction rather than a
preposition, and for some people that's fine -- the sentence is just an
elliptical form of the version with the verb ("am") present.
For others, it sounds stilted and old fashioned. I'd say that calling
it "misuse" is stretching the point but, which ever way you see it,
I'd bet that the younger the kids the _more_ likely they would be to
spot is. The trend is definitely away from anything that sounds so
formal.
Without a following clause that needs a subject (i.e. when the verb "am"
is missing) the use of "me" forces "than" to be seen as a preposition.
This is nothing new (it's been happening for centuries) and I don't
think there can be any serious objection to it these days. In that
sense, "me" is better here and I'd bet that most people would prefer it
over "I".
It's interesting to note that this conjunction/preposition distinction
sometimes makes a lot of difference. In Henry VI, Part III the king
says:
Then why should they love Edward more than me?
Had he said "than I" it would have meant something else entirely.
</OT>
These days people prefer to mess around for hours getting all the text
correctly lined up in their word processor. It's called progress
(e-mail address removed) ha scritto:
unless of course you substitute "one or a few" with "many" ...
(e-mail address removed) ha scritto:
suppose you had to fill several dozens of forms, or worse several
hundreds (happened recently at my workplace).
they give you a bunch of paper forms, then you have to fill them, with
data that is stored digitally somewhere, or that you have to firstly
store for later usage (maybe some more forms are on the way).
see?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.