Re: [SLUG] Wanting to learn C - book suggestions?

From: Dylan Hardison (dylanwh@gmail.com)
Date: Fri Mar 11 2005 - 01:58:20 EST


On Thu, 10 Mar 2005 21:19:19 -0500, Ken Elliott
<kelliott4@tampabay.rr.com> wrote:
> >>printf("\n");
>
> >>has more characters than
>
> >>echo ""
>
> >>plus compilation. Not to say it's a _bad_ method, though.
>
> Yes, but the C version prints nothing _so_ much faster...
>
> main() {prinf("doh!\n")}

Nitpick: Technically that's not correct ANSI C.

* The return type (int) should be specified.
* printf is not declared.
* printf really shouldn't be used for this, puts should be. Some (stupid)
   implementations of varargs don't handle vararg functions with only
on argument.
* the semicolon after printf is missing.
* There is no return statement. main must return an integer value.

Though, at least you didn't write "void main".
That's so completely incorrect, and I can't say how many times I've
seen people type that on slashdot...

A correct implementation would be:
#include <stdio.h>
int main() {
    puts("doh!");
    return 0;
}

Sorry for being pedantic and nit-picky, I had to deal with some very
ugly non-standard C code today. :)
-----------------------------------------------------------------------
This list is provided as an unmoderated internet service by Networked
Knowledge Systems (NKS). Views and opinions expressed in messages
posted are those of the author and do not necessarily reflect the
official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 20:30:36 EDT