The importance of showing ALL of the code in C

From: Fred Cisin <cisin_at_xenosoft.com>
Date: Wed Feb 6 12:59:35 2002

On Wed, 6 Feb 2002, Julius Sridhar wrote:
> Capitalization.
> Peace... Sridhar

Even without my failure to maintain case in the variable, it would still
return 2 instead of 7 due to premature termination of conditional
expression (semicolon), and due to assignment instead of comparison in
condition (= instead of ==). Amongst folks as careless as myself, those
two seem to be the two most common typos in C programs.


> > Two more common mistakes: (that means ones that I do frequently)
> >
> > N = 2;
> > X = 3;
> > . . .
> > if (x > 10);
> > {
> > return(N);
> > }
> > N = 7;
> > return(N);
> >
> > and:
> >
> > N = 2;
> > X = 3;
> > . . .
> > if (x = 10)
> > {
> > return(N);
> > }
> > N = 7;
> > return(N);
> >
> > Look for why both sections return 2 instead of 7.
Received on Wed Feb 06 2002 - 12:59:35 GMT

This archive was generated by hypermail 2.3.0 : Fri Oct 10 2014 - 23:34:44 BST