<code>
line = 1;
while( !feof( infile ) )
{
if( line = 2 )
{
fgets( name, 25, infile );
}
else if( line = 3 )
{
fgets( address, 80, infile );
strcat( tempaddress, address );
if( strcmp( address, "?" ) == 0 )
{
line = 4;
}
}
else if( line = 4 )
{
fgets( yearofbirth, 5, infile );
}
else if( line = 5 )
{
fgets( telno, 15, infile );
}
line++;
printf( "%s%s%s%s", name, address, yearofbirth, telno );
addRecord( rptrp , name, address, atoi(yearofbirth), telno
);
}
</code>
I wonder if someone can help me out. For some reason, this while loop
doesn't update. line is always set to 1. i'm trying to get each line
and store it in each array.
Posted at: http://www.groupsrv.com
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
---------------------------------------------------------- http://www.usenet.com 42 1592
slickn_sly wrote: line = 1; while( !feof( infile ) )
^^^^^^^^^^^^^^^^^^^^^^^^
This is a mistake; check the FAQ, your C textbook, or any of a large
number of previous threads for details. { if( line = 2 )
^^^^^^^^^^^^
This, and all subsequent conditions like it, are almost certainly a
mistake. '=' is the assignment operator; '==' is the equality
comparison operatior.
Martin Ambuhl wrote: slickn_sly wrote:
.... snip ... { if( line = 2 ) ^^^^^^^^^^^^ This, and all subsequent conditions like it, are almost certainly a mistake. '=' is the assignment operator; '==' is the equality comparison operatior.
Which you can easily avoid at all times by simply cultivating the
habit of writing:
if (2 == line) ...
i.e. put the constant first.
--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
"CBFalconer" <cb********@yahoo.com> wrote in message
news:42***************@yahoo.com... Martin Ambuhl wrote: slickn_sly wrote: ... snip ... { if( line = 2 ) ^^^^^^^^^^^^ This, and all subsequent conditions like it, are almost certainly a mistake. '=' is the assignment operator; '==' is the equality comparison operatior.
Which you can easily avoid at all times by simply cultivating the habit of writing:
if (2 == line) ...
i.e. put the constant first.
Or since the OP is using multiple constants, a neater approach would be to
use a switch() statement.
Allan do*@dot.dot spoke thus: while( !feof( infile ) ) http://www.eskimo.com/~scs/C-faq/q12.2.html
(Martin already pointed this out to OP.)
--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
CBFalconer wrote: Martin Ambuhl wrote: slickn_sly wrote:
if( line = 2 ) ^^^^^^^^^^^^
Which you can easily avoid at all times by simply cultivating the habit of writing:
if (2 == line) ...
i.e. put the constant first.
Which you can as easily avoid at all times without any cultivation
by letting the compiler warn you.
P.Krumins
In article <42***************@yahoo.com>, CBFalconer wrote: Martin Ambuhl wrote: slickn_sly wrote: ... snip ... { if( line = 2 ) ^^^^^^^^^^^^ This, and all subsequent conditions like it, are almost certainly a mistake. '=' is the assignment operator; '==' is the equality comparison operatior.
Which you can easily avoid at all times by simply cultivating the habit of writing:
if (2 == line) ...
i.e. put the constant first.
I don't like this habit for various reasons:
1) Though the reversed version is semantically equivalent, it is harder
to read unless you are already quite used to reversing the test. The
vast majority of programmers always puts the variable they want to test
first, i.e. they write
if (foo == 0) {
The few who write
if (0 == foo) {
.... are extremely likely to do so only because they want to avoid the
comparison vs. assignment problem. (If any of the c.l.c regulars started
to use the latter version for reasons other than the mixed up operators
thing, please stand up.)
This is evidence enough that the former version is more natural, and it
follows that the latter is harder to read and understand, regardless of
the fact that it means the same thing. The fact that writing ``0 ==
foo'' is generally considered to be a programming trick is additional
evidence that it is NOT the natural way to code this.
2) If you can remember to reverse the check every time, you also ought
to be able to remember simply to use ``=='' whenever you mean ``=='',
which would save you the trouble of making your code less readable.
The reversal also only makes any sense for C beginners; Sooner or
later you *will* get used to its equality operator, and the reversed
test only serves the purpose of decreasing code readability anymore.
3) Quality compilers warn about the ``if (foo = 0)'' construct. I know
for a fact only that gcc and HP's compilers do this (and not because the
bug ever occured to me, but because I explictly tested these compilers),
but it is very likely that the offerings of vendors such as Comeau,
Compaq, Intel, SGI, IBM, Sun and a host of others are also capable of
doing this (I don't have these compilers handy right now and will let
others fill in the blanks.)
4) It is not even a reliable way to avoid the problem because it works
well only for constants!
if (foo = bar) {
and
if (bar = foo) {
.... both silently produce (probably) incorrect results (modulo corner
cases like the operand on the left-hand side being ``const''-qualified.)
(It will probably take me a couple of days to reply to any followups -
should I consider them interesting enough to reply - because the free
access to my newsserver is being terminated and I haven't yet registered
a commercial account.)
--
My real email address is ``nils<at>gnulinux<dot>nl''
Nils Weller wrote: CBFalconer wrote:
.... snip ... Which you can easily avoid at all times by simply cultivating the habit of writing:
if (2 == line) ...
i.e. put the constant first.
I don't like this habit for various reasons:
1) Though the reversed version is semantically equivalent, it is harder to read unless you are already quite used to reversing the test. The vast majority of programmers always puts the variable they want to test first, i.e. they write
if (foo == 0) {
The few who write
if (0 == foo) {
.... snip ... 3) Quality compilers warn about the ``if (foo = 0)'' construct. I know for a fact only that gcc and HP's compilers do this (and not because the bug ever occured to me, but because I explictly tested these compilers), but it is very likely that the offerings of vendors such as Comeau, Compaq, Intel, SGI, IBM, Sun and a host of others are also capable of doing this (I don't have these compilers handy right now and will let others fill in the blanks.)
And I dislike that warning. I often want to write something like:
if (!(p = malloc(sizeof *p))) getoutahere("no memory");
else if (!(p->ptr = malloc(sizeof *p->ptr))) {
free(p); getoutahere("no memory");
}
else {
/* all seems well, go for it */
}
/* Unless getoutahere does something, we always get here */
and similar things to do with opening files, getting parameters,
etc.
--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
On Thu, 31 Mar 2005 23:43:41 GMT, CBFalconer
<cb********@yahoo.com> wrote: Nils Weller wrote: 3) Quality compilers warn about the ``if (foo = 0)'' construct. I know for a fact only that gcc and HP's compilers do this (and not because the bug ever occured to me, but because I explictly tested these compilers), but it is very likely that the offerings of vendors such as Comeau, Compaq, Intel, SGI, IBM, Sun and a host of others are also capable of doing this (I don't have these compilers handy right now and will let others fill in the blanks.)
And I dislike that warning. I often want to write something like:
if (!(p = malloc(sizeof *p))) getoutahere("no memory"); else if (!(p->ptr = malloc(sizeof *p->ptr))) { free(p); getoutahere("no memory"); } else { /* all seems well, go for it */ } /* Unless getoutahere does something, we always get here */
and similar things to do with opening files, getting parameters, etc.
Quality compilers (GCC derived ones, for example) note the extra
parentheses around the assignment and don't produce the warning:
if (p = q) ... /* warning */
if ((p = q)) ... /* no warning */
if (!(p = q)) ... /* no warning */
The first could be a mistake, the second and third are likely to be
intentional.
Although I prefer the clearer:
p = q;
if (p) ...
in most cases (idioms with for and while loops and inputting data are
about the only times I use the contraction, I don't do it in an if
test).
Chris C do*@dot.dot writes: On 31 Mar 2005 21:59:13 GMT, Nils Weller <me@privacy.net> wrote:
[...] Easy solution...
#define is ==
int x = 10;
if (x is 10) puts("it worked");
That will make your code difficult to read. Do you actually do this
yourself? 3) Quality compilers warn about the ``if (foo = 0)'' construct.
It should be a syntax error.
In a different language, sure. In C, an assignment is an expression
that yields the value assigned; changing that would break too much
existing code.
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this. do*@dot.dot wrote: Keith Thompson <ks***@mib.org> wrote:
3) Quality compilers warn about the ``if (foo = 0)'' construct.
It should be a syntax error.
In a different language, sure. In C, an assignment is an expression that yields the value assigned; changing that would break too much existing code.
If the compiler can detect it sufficiently to warn, it can hand out an error, stop compilation and force you to fix it. And how many perfectly good programs have come crashing down over this one simple error? Even worse when comparisons ( < and > ) are single characters... it's confusing.
Except now you are using 'not C'. The value of an assignment is
often useful, as in:
if (err = setupphase(1)) bitchabout(1, err);
else if (err = setupphase(2)) bitchabout(2, err);
else if (err = setupphase(3)) bitchabout(3, err);
else {
/* The sun is out and the birds are singing */
}
/* And we always get here, possibly with err set */
--
Some useful references about C:
<http://www.ungerhu.com/jxh/clc.welcome.txt>
<http://www.eskimo.com/~scs/C-faq/top.html>
<http://benpfaff.org/writings/clc/off-topic.html>
<http://anubis.dkuug.dk/jtc1/sc22/wg14/www/docs/n869/> (C99)
<http://www.dinkumware.com/refxc.html> (C-library}
<http://gcc.gnu.org/onlinedocs/> (GNU docs)
CBFalconer <cb********@yahoo.com> spoke thus: Except now you are using 'not C'. The value of an assignment is often useful, as in:
if (err = setupphase(1)) bitchabout(1, err);
Yes, that's very convenient, although my implementation at least will
generate a warning. I don't know if gcc does, and I wonder whether
lint and friends will complain.
--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome. do*@dot.dot writes: On Sat, 02 Apr 2005 20:00:39 GMT, Keith Thompson <ks***@mib.org> wrote:
3) Quality compilers warn about the ``if (foo = 0)'' construct.
It should be a syntax error.
Please don't snip nested attributions.
In a different language, sure. In C, an assignment is an expression that yields the value assigned; changing that would break too much existing code. If the compiler can detect it sufficiently to warn, it can hand out an error, stop compilation and force you to fix it. And how many perfectly good programs have come crashing down over this one simple error? Even worse when comparisons ( < and > ) are single characters... it's confusing.
You can't make "=" not yield a value without breaking existing
programs. Making an assignment invalid in a condition but valid
elsewhere would be an ugly wart.
I don't find the fact that '<' and '>' are single characters confusing
at all. They match mathematical notation.
Frankly, it would have made more sense to have the testing done on a single =, & or | marks and use the doubles for assignment along with >> and << which are used for bit shifts.
Think about it... 1 letter: compare, 2 letters: perform an operation. (or visa versa) It would be totally consistent. As it is now the rule is 1 letter does an operation EXCEPT for bit shifts, 2 letters does a test EXCEPT for less and greater. It's inconsistent and when learning I found it confusing as all get out.
I've never assumed that the number of characters in an operator has
any significance. I just learned what each one means.
So I have a little header I use with a bunch of defines...
#define is == #define lt < #define gt > #define ne != #define or || #define and && #define shiftl << #define shiftr >> etc.
Gives me syntax like this:
if (x and (y lt 7))
if ((x lt y) or (y is 7))
No more silly mistakes.
If I were going to do something like that, I'd use "eq" rather than
"is" for equality. (Some languages distinguish between equality and
identity, and use "is" for the latter.) I'd also use the symbols in
<iso646.h> whenever possible, and try to be consistent with them
otherwise.
But I'd much rather just learn the language and use it. If I'm going
to read your code, I have to undertand the language *and* the macros
you've chosen. For this:
if (x && (y < 7))
if ((x < y) || (y == 7))
I just have to know the language.
You can use your macros if you like, but I guarantee they'll make it
more difficult for anyone else to read or maintain your code.
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this. do*@dot.dot writes: On Sat, 02 Apr 2005 22:44:02 GMT, CBFalconer <cb********@yahoo.com> wrote:Except now you are using 'not C'. The value of an assignment is often useful, as in:
if (err = setupphase(1)) bitchabout(1, err); else if (err = setupphase(2)) bitchabout(2, err); else if (err = setupphase(3)) bitchabout(3, err); else {
In which case I use assignment, not tests to get the job done.
So, exactly what's the problem?
The problem is that you would make the above valid code illegal. The
alternative would be significantly more verbose. I suppose you could
do this:
if (err = setupphase(1), err) bitchabout(1, err);
else if (err = setupphase(2), err) bitchabout(2, err);
else if (err = setupphase(3), err) bitchabout(3, err);
else {
but frankly I find the first form clearer.
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1 do*@dot.dot wrote: On Sat, 02 Apr 2005 20:00:39 GMT, Keith Thompson <ks***@mib.org> wrote:
3) Quality compilers warn about the ``if (foo = 0)'' construct.
It should be a syntax error. In a different language, sure. In C, an assignment is an expression that yields the value assigned; changing that would break too much existing code.
If the compiler can detect it sufficiently to warn, it can hand out an error, stop compilation and force you to fix it.
Sorry, but while it might warrant a "suspicious construct" type warning from
the compiler, that code model certainly isn't /broken/, and doesn't warrant an
error that stops compilation.
Consider this fragment...
if (c = Get_Users_Choice()) printf("The user chose %c\n",c);
If, for instance, while developing or debugging this fragment, the programmer
decided to 'stub' the Get_Users_Choice() function with
#define Get_Users_Choice() 'N'
then the compilation would generate (after macro expansion)
if (c = 'N') printf("The user chose %c\n",c);
While this is not a /usefull/ code construct (from the point of view of
offering the intended variety of values to c), it is a /necessary/ and /legal/
construct.
And how many perfectly good programs have come crashing down over this one simple error?
Probably fewer than those that come crashing down on off-by-one errors or
subscript_out_of_bounds errors.
Even worse when comparisons ( < and > ) are single characters... it's confusing.
To you, perhaps, but not to a professional (or even an experienced amateur)
programmer.
Frankly, it would have made more sense to have the testing done on a single =, & or | marks and use the doubles for assignment along with >> and << which are used for bit shifts.
That's your opinion. You are welcome to move to that language, what ever it
is. It isn't C, though.
Think about it... 1 letter: compare, 2 letters: perform an operation. (or visa versa) It would be totally consistent. As it is now the rule is 1 letter does an operation EXCEPT for bit shifts, 2 letters does a test EXCEPT for less and greater. It's inconsistent and when learning I found it confusing as all get out.
You get confused easily, I see.
So I have a little header I use with a bunch of defines...
#define is == #define lt < #define gt > #define ne != #define or || #define and && #define shiftl << #define shiftr >>
Reminds me of the poster a decade back or so who posted macros that made C
look "pascal-like". Macros of the sort of
#define BEGIN {
#define END }
Just as useless, too.
- --
Lew Pitcher
Master Codewright & JOAT-in-training | GPG public key available on request
Registered Linux User #112576 ( http://counter.li.org/)
Slackware - Because I know what I'm doing.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFCTzVBagVFX4UWr64RApm9AKCnGeb8ZsGsPEIWskwzmz vvY19JHQCg6ibw
rtB1GuiKvbYFKei8WlKQUZI=
=OYZX
-----END PGP SIGNATURE-----
Christopher Benson-Manica wrote: CBFalconer <cb********@yahoo.com> spoke thus:
Except now you are using 'not C'. The value of an assignment is often useful, as in:
if (err = setupphase(1)) bitchabout(1, err);
Yes, that's very convenient, although my implementation at least will generate a warning. I don't know if gcc does, and I wonder whether lint and friends will complain.
gcc will make muttering noises about using extra parentheses, after
which it will quieten down. The real point is that it is easy to
see what preconditions (and in what order) are needed to attain
singing birds.
--
Some useful references about C:
<http://www.ungerhu.com/jxh/clc.welcome.txt>
<http://www.eskimo.com/~scs/C-faq/top.html>
<http://benpfaff.org/writings/clc/off-topic.html>
<http://anubis.dkuug.dk/jtc1/sc22/wg14/www/docs/n869/> (C99)
<http://www.dinkumware.com/refxc.html> (C-library}
<http://gcc.gnu.org/onlinedocs/> (GNU docs) do*@dot.dot wrote in news:kr********************************@4ax.com: If I were writing what you have above I would write...
if (err = setupphase(1)) bitchabout(1, err); else if (err = setupphase(2)) bitchabout(2, err); else if (err = setupphase(3)) bitchabout(3, err); else { ...
So tell me again... what exactly is the problem?
You snipped the part where you proposed that assignment within if( ... )
be made a syntax error. That is, if your own proposal is adopted, you
would not be able to write what you just wrote. Instead, you would have
to write
err = setupphase(1);
if(err)
bitchabout(1, err);
etc.
Sinan
--
A. Sinan Unur <1u**@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW: http://mail.augustmail.com/~tadmc/cl...uidelines.html do*@dot.dot wrote: On Sun, 03 Apr 2005 00:00:20 GMT, Keith Thompson <ks***@mib.org> wrote:
You can use your macros if you like, but I guarantee they'll make it more difficult for anyone else to read or maintain your code.
See that's just is... *nobody* will ever see or maintain my code.
Believe me... it just won't happen.
In that case, your style of coding is bad.
A good style, is one which makes the code easy to maintain
by someone who has never seen the code before.
--
pete do*@dot.dot writes: On Sun, 03 Apr 2005 00:04:27 GMT, Keith Thompson <ks***@mib.org> wrote:
do*@dot.dot writes: On Sat, 02 Apr 2005 22:44:02 GMT, CBFalconer <cb********@yahoo.com> wrote: Except now you are using 'not C'. The value of an assignment is often useful, as in:
if (err = setupphase(1)) bitchabout(1, err); else if (err = setupphase(2)) bitchabout(2, err); else if (err = setupphase(3)) bitchabout(3, err); else {
In which case I use assignment, not tests to get the job done.
So, exactly what's the problem?
The problem is that you would make the above valid code illegal.
How exactly does using a couple of aliases the cut down on errors make that code illegal?
If I were writing what you have above I would write...
if (err = setupphase(1)) bitchabout(1, err); else if (err = setupphase(2)) bitchabout(2, err); else if (err = setupphase(3)) bitchabout(3, err); else { ...
So tell me again... what exactly is the problem?
I have no idea. Your code is identical to CBFalconer's code except
that you split the lines. You've objected to using an assignment as a
condition; now you post code that does exactly that.
I have no problem with the code you just posted; it just seems to
contradict what you've been saying.
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this. do*@dot.dot writes: On Sun, 03 Apr 2005 02:06:09 GMT, pete <pf*****@mindspring.com> wrote:
A good style, is one which makes the code easy to maintain by someone who has never seen the code before. But, as I keep trying to get through your noggin... Nobody's ever going to see my source code... I am the only person who will ever have to read or revise anything I've written.
Then you're in an unusual position. If it works for you, and if
nobody else will ever have to deal with it, there's not much reason
anybody else should care.
I find that good style leads to more reliable code. I also try to
keep in mind that I may have to maintain the code myself years from
now. I don't like to think of my future self asking what the hell I
was thinking when I wrote this stuff (as I've done sometimes when
reading my own old code).
Really... I work alone, on a contract basis. It is *understood* contractually that I do not share or divulge source code to *anyone*. I plan taking my secrets to the grave with me.
I probably wouldn't work with someone on those terms.)
but that's between you and whoever you work with.
[snip]
Why this bothers people here so much is beyond me.
Because you told us about it. If you keep it to yourself, nobody will
know or care. If you choose to share it, people will offer their
opinions. If you didn't want our opinions on your coding style, I'm
at a loss to understand why you posted about it.
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Keith Thompson wrote: do*@dot.dot writes:
.... snip ... If I were writing what you have above I would write...
if (err = setupphase(1)) bitchabout(1, err); else if (err = setupphase(2)) bitchabout(2, err); else if (err = setupphase(3)) bitchabout(3, err); else { ...
So tell me again... what exactly is the problem?
I have no idea. Your code is identical to CBFalconer's code except that you split the lines. You've objected to using an assignment as a condition; now you post code that does exactly that.
Except in the process he has lost the clarity, in that it no longer
as clearly shows the prerequiristes satisfied to allow the action.
--
Some useful references about C:
<http://www.ungerhu.com/jxh/clc.welcome.txt>
<http://www.eskimo.com/~scs/C-faq/top.html>
<http://benpfaff.org/writings/clc/off-topic.html>
<http://anubis.dkuug.dk/jtc1/sc22/wg14/www/docs/n869/> (C99)
<http://www.dinkumware.com/refxc.html> (C-library}
<http://gcc.gnu.org/onlinedocs/> (GNU docs) do*@dot.dot wrote in news:3k********************************@4ax.com: look more closely at what I've been saying. I've been trying to make a point about consistent rules within the language.
Assignment ... =, &, |, <, >, % Testing ... ==, &&, ||, <<, >>, %%
Hmmm ... where is the assignment in
if(a < c) { ... }
... this whole discussion is getting a little silly.
Absolutely.
Sinan
--
A. Sinan Unur <1u**@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW: http://mail.augustmail.com/~tadmc/cl...uidelines.html
On Sat, 02 Apr 2005 17:00:06 -0500, in comp.lang.c , do*@dot.dot
wrote: On Sat, 02 Apr 2005 20:00:39 GMT, Keith Thompson <ks***@mib.org> wrote:
3) Quality compilers warn about the ``if (foo = 0)'' construct.
It should be a syntax error. In a different language, sure. In C, an assignment is an expression that yields the value assigned; changing that would break too much existing code.
If the compiler can detect it sufficiently to warn, it can hand out an error, stop compilation and force you to fix it.
point is, it might be able to warn you, but its a perfectly legal
construct, and one that many people use deliberately.
Frankly, it would have made more sense to have the testing done on a single =, & or | marks and use the doubles for assignment along with >> and << which are used for bit shifts.
If you have a time machine, pop back thirty odd years and mention that
to the designers of BCPL and B. Otherwise, you'll need to discuss it
in the context of a new language.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>
On Sat, 02 Apr 2005 20:47:27 -0500, in comp.lang.c , do*@dot.dot
wrote: On Sun, 03 Apr 2005 00:00:20 GMT, Keith Thompson <ks***@mib.org> wrote:
You can use your macros if you like, but I guarantee they'll make it more difficult for anyone else to read or maintain your code. See that's just is... *nobody* will ever see or maintain my code.
And with luck, nobody will ever see your backside. Thats no reason to
leave it all covered in sh...
Believe me... it just won't happen.
so what? Is that a good reason to learn bad habits?
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt> do*@dot.dot wrote: On Sun, 03 Apr 2005 02:06:09 GMT, pete <pf*****@mindspring.com> wrote:
A good style, is one which makes the code easy to maintain by someone who has never seen the code before.
Why this bothers people here so much is beyond me.
Because you have been advocating your style.
--
pete do*@dot.dot writes: On Sun, 03 Apr 2005 23:10:53 GMT, pete <pf*****@mindspring.com> wrote:Because you have been advocating your style.
Sorry... I've done no such thing. Discussion is not advocacy.
Upthread:
] >3) Quality compilers warn about the ``if (foo = 0)'' construct.
]
] It should be a syntax error.
I'm not sure of the attributions, but the "It should be a syntax
error." was yours. Looks like advocacy to me.
It really doesn't matter to me whether you were advocating anything or
not. All anybody has been doing here is discussing things. That's
what this newsgroup is for.
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this. do*@dot.dot spoke thus:
(Chuck and Keith, it's going to sound like I'm trying to curry favor
with you, but I promise that's not the case!) Well, except for you and Falconer who seem mostly concerned with litigating a case against every posting that doesn't fit your ideal guidelines.
You do realize you're taking a confrontational stance toward two of
the most respected members of the comp.lang.c group, right?
Really... It's effing amazing to watch the self-appointed group leaders on Usenet litigate their way to dominance and control, mostly by nitpicking posts and defaming participants.
Self-appointed nothing - they got that way by consistently being both
deifically knowledgeable and unflaggingly helpful. The rules are
simple, and they aren't creations of a cabal of regular posters. As
smart as they are, they didn't invent netiquette.
I came here to discuss C ... so far I've been ruled off topic, ordered out of the group, lectured about etiquette and now subjected to micro-analysis of my ever word.
Why not learn from your mistakes rather than perpetuating them?
What's next?
Plonks?
--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome. do*@dot.dot wrote: On Mon, 04 Apr 2005 03:16:55 GMT, Keith Thompson <ks***@mib.org> wrote:
All anybody has been doing here is discussing things. That's what this newsgroup is for.
I came here to discuss C ...
We were just discussing how bad your coding style is.
It's very bad.
--
pete do*@dot.dot wrote: So I have a little header I use with a bunch of defines...
#define is == #define lt < #define gt > #define ne != #define or || #define and && #define shiftl << #define shiftr >>
Blech. IYWPYKWTFI.
Richard
Keith Thompson <ks***@mib.org> wrote: do*@dot.dot writes: On 31 Mar 2005 21:59:13 GMT, Nils Weller <me@privacy.net> wrote: [...] Easy solution...
#define is ==
int x = 10;
if (x is 10) puts("it worked");
That will make your code difficult to read.
So will the usual reversed-operand trick. The easy solution is learning
to pay attention.
Richard do*@dot.dot wrote: On Mon, 04 Apr 2005 09:45:05 GMT, pete <pf*****@mindspring.com> wrote:
We were just discussing how bad your coding style is. It's very bad. And exactly when have you seen my source code?
I believe it was 2 April 2005. It looked like this: So I have a little header I use with a bunch of defines...
#define is == #define lt < #define gt > #define ne != #define or || #define and && #define shiftl << #define shiftr >> etc.
Gives me syntax like this:
if (x and (y lt 7))
if ((x lt y) or (y is 7))
Only an idiot pronounces judgement without evidence.
I don't see how that's relevant.
--
pete do*@dot.dot wrote: pete <pf*****@mindspring.com> wrote:
We were just discussing how bad your coding style is. It's very bad.
And exactly when have you seen my source code? Only an idiot pronounces judgement without evidence.
The following appeared in this thread earlier. Are we to conclude
they were either forged or the words of an idiot? They do seem to
describe some idiots programming style. They were combined with a
recommendation that legitimate C statements be flagged as syntax
errors. So I have a little header I use with a bunch of defines...
#define is == #define lt < #define gt > #define ne != #define or || #define and && #define shiftl << #define shiftr >>
--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson rl*@hoekstra-uitgeverij.nl (Richard Bos) writes: Keith Thompson <ks***@mib.org> wrote:
do*@dot.dot writes: > On 31 Mar 2005 21:59:13 GMT, Nils Weller <me@privacy.net> wrote: [...] > Easy solution... > > #define is == > > int x = 10; > > if (x is 10) > puts("it worked");
That will make your code difficult to read.
So will the usual reversed-operand trick. The easy solution is learning to pay attention.
I agree, but there are enough competent programmers who use the
reversed-operand trick, and who actually like it, that the rest of us
just have to learn to read it, even if we'd never write it.
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this. do*@dot.dot spoke thus: Ok, now I see... you're just an idiot looking for a fight.
My sentiments exactly...
*plonk*
--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome. do*@dot.dot writes:
[snip] Ok, now I see... you're just an idiot looking for a fight.
"dot": You are overreacting. I suggest we all drop this current
discussion and go back to talking about C, and I suggest that everyone
else refrain from responding to what might be perceived as trollish
behavior on dot's part. We don't need yet another interminable
argument about nothing in particular.
I'm not optimistic that my attempt to end this will be successful, but
I'm prepared to be pleasantly surprised.
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
On Sat, 02 Apr 2005 20:53:42 -0500, do*@dot.dot
<do*@dot.dot> wrote: On Sat, 02 Apr 2005 19:13:53 -0500, Lew Pitcher <lp******@sympatico.ca> wrote:
So I have a little header I use with a bunch of defines...
#define is == #define lt < #define gt > #define ne != #define or || #define and && #define shiftl << #define shiftr >> Reminds me of the poster a decade back or so who posted macros that made C look "pascal-like". Macros of the sort of #define BEGIN { #define END }
Just as useless, too.
Given that in my learning phase this cut the number of errors I was making to less than a third... not useless.
I remember many years ago some education theorists brought out the
Initial Teaching Alphabet, which was basically English spelt
phonetically. It was designed to make learning to write easier -- and
it worked, children who learnt ITA indeed made fewer mistakes and found
it easier.
There were just a few problems:
Other people couldn't understand ITA.
The children couldn't understand ordinary written English.
A large proportion of the children /never/ learnt ordinary English
spellings, they were fine at their own version but not at the "real
world" one.
Lately I don't use them all that much ... you see I'm learning... eventually I'll most likely abandon them altogether.
Well, it depends why you are bothering to learn C. If it's only a
hobby, and you never need to understand what anyone else writes and they
never need to understand you, then that's fine, write in any language
you like (including ones you invent). But if you ever want to come out
into the real world and talk with the grown-ups, you need to bite the
bullet and learn the real language.
Chris C
On Sun, 03 Apr 2005 23:46:20 -0400, in comp.lang.c , do*@dot.dot
wrote: Well, except for you and Falconer who seem mostly concerned with litigating a case against every posting that doesn't fit your ideal guidelines.
Actually CBF and Keith mostly help people round here. True, they can
sometimes be grumpy with persistently idiotic posters, but so can we
all. And a top tip: its a bad plan to start a fight with the regulars,
you find you get less help from them afterwards.
Really... It's effing amazing to watch the self-appointed group leaders on Usenet litigate their way to dominance and control, mostly by nitpicking posts and defaming participants.
There /.are/ no group leaders. Those who comment authoratively do so
by reason of being experienced and having knowledge.
I came here to discuss C ... so far I've been ruled off topic, ordered out of the group, lectured about etiquette and now subjected to micro-analysis of my ever word.
Then why not learn from your mistakes, stop posting offtopic, stop
being rude, and stop pushing your micro-style on everyone else?
What's next? Bamboo under my toenails?
Code review. :-)
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>
On Mon, 04 Apr 2005 09:34:58 -0400, in comp.lang.c , do*@dot.dot
wrote: On Mon, 04 Apr 2005 09:45:05 GMT, pete <pf*****@mindspring.com> wrote:
We were just discussing how bad your coding style is. It's very bad. And exactly when have you seen my source code?
Just what you've posted. And its bad. If there's better, please post
some of it so we may judge again
Only an idiot pronounces judgement without evidence.
Fatuous, but it is true that only an idiot expects to be treated with
consideration after hurling insults and invective.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>
On Mon, 04 Apr 2005 18:44:00 -0400, in comp.lang.c , do*@dot.dot
wrote: On Mon, 4 Apr 2005 21:45:56 +0100, Chris Croughton <ch***@keristor.net> wrote:
But if you ever want to come out into the real world and talk with the grown-ups, you need to bite the bullet and learn the real language. Ohhh... bad assumption. I've never said I wasn't about to learn C.
Then I think the consensus recommendation is to *learn* it, rather
than trying to make it into something its not, because either you
don't like or don't understand how it works.
you would see that *twice now* I've pointed out that my little "easy header" was a learning tool that I don't use much anymore...
good. Perhaps you should have mentioned that at the outset, or said it
louder later on, but these things happen.
Now what part of "don't use much anymore" don't you understand?
The part where you didn't say that in any post I've seen (till this
one)
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>
Mark McIntyre <ma**********@spamcop.net> spoke thus: The part where you didn't say that in any post I've seen (till this one)
In his defense, he did say it, although I couldn't tell you in which
post.
--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
On Mon, 04 Apr 2005 21:24:19 -0400, in comp.lang.c , do*@dot.dot
wrote: On Tue, 05 Apr 2005 00:16:49 +0100, Mark McIntyre <ma**********@spamcop.net> wrote:
Then I think the consensus recommendation is to *learn* it, rather than trying to make it into something its not, because either you don't like or don't understand how it works. And you got a complete critique of my competence from a simple #define showing a way to avoid beginner's mistakes?
no, from a combination of your initial posting, your belligerent
defense of it in the face of almost universal criticism, your
insistence that certain things should be errors which plainly should
not be, your insistence that its a way to avoid beginners mistakes and
so forth.
WOW... now THAT is impressive. Can I borrow your crystal ball sometime?
Certainly.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>
On Mon, 4 Apr 2005 23:52:09 +0000 (UTC), in comp.lang.c , Christopher
Benson-Manica <at***@nospam.cyberspace.org> wrote: Mark McIntyre <ma**********@spamcop.net> spoke thus:
The part where you didn't say that in any post I've seen (till this one)
In his defense, he did say it, although I couldn't tell you in which post.
fair enough, I didn't see that post, such is usenet. My apologies to
dot for missing it.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: mike |
last post by:
Hello,
After trying to validate this page for a couple of days now I was
wondering if someone might be able to help me out. Below is a list of
snippets where I am having the errors.
1. Line 334,...
|
by: John Flynn |
last post by:
hi all
i'm going to be quick i have an assignment due which i have no idea how to
do. i work full time so i dont have the time to learn it and its due date
has crept up on me ..
As follows:...
|
by: xunling |
last post by:
i have a question about answering ..... this topic is "need help"
what do i have to write at te topic line, !after i have klicked the
"answer message" button
ive tried many possibilities,...
|
by: sk |
last post by:
I have an applicaton in which I collect data for different parameters
for a set of devices. The data are entered into a single table, each
set of name, value pairs time-stamped and associated with...
|
by: Timothy Shih |
last post by:
Hi, I am trying to figure out how to use unmanaged code using P/Invoke. I
wrote a simple function which takes in 2 buffers (one a byte buffer, one a
char buffer) and copies the contents of the byte...
|
by: Cheryl Langdon |
last post by:
Hello everyone,
This is my first attempt at getting help in this manner. Please
forgive me if this is an inappropriate request.
I suddenly find myself in urgent need of instruction on how to...
|
by: pamelafluente |
last post by:
I am still working with no success on that client/server
problem. I need your help. I will submit simplified versions
of my problem so we can see clearly what is going on.
My model:
A client...
|
by: skumar434 |
last post by:
i need to store the data from a data base in to structure
.............the problem is like this ....suppose there is a data base
which stores the sequence no and item type etc ...but i need only...
|
by: U S Contractors Offering Service A Non-profit |
last post by:
Brilliant technology helping those most in need Inbox
Reply
U S Contractors Offering Service A Non-profit
show details
10:37 pm (1 hour ago)
Brilliant technology helping those most in need ...
|
by: mike |
last post by:
I help manage a large web site, one that has over
600 html pages... It's a reference site for ham radio
folks and as an example, one page indexes over
1.8 gb of on-line PDF documents.
The site...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |