K&R Answers?

Discussion in 'C Programming' started by Zach, Mar 15, 2008.

  1. Zach

    Zach Guest

    I recall someone posting a website that had the complete K&R (2nd Ed.
    - ANSI) answers posted but I cannot find the post.

    Zach
    Zach, Mar 15, 2008
    #1
    1. Advertising

  2. Zach said:

    > I recall someone posting a website that had the complete K&R (2nd Ed.
    > - ANSI) answers posted but I cannot find the post.


    Not complete (if I recall correctly) - but the Web site you're looking for
    is:

    <http://clc-wiki.net/wiki/K%26R2_solutions>

    --
    Richard Heathfield <http://www.cpax.org.uk>
    Email: -http://www. +rjh@
    Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
    "Usenet is a strange place" - dmr 29 July 1999
    Richard Heathfield, Mar 16, 2008
    #2
    1. Advertising

  3. Zach

    Zach Guest

    On Mar 15, 8:09 pm, Richard Heathfield <> wrote:
    > Zach said:
    >
    > > I recall someone posting a website that had the complete K&R (2nd Ed.
    > > - ANSI) answers posted but I cannot find the post.

    >
    > Not complete (if I recall correctly) - but the Web site you're looking for
    > is:
    >
    > <http://clc-wiki.net/wiki/K%26R2_solutions>


    Thanks Richard.

    Zach
    Zach, Mar 16, 2008
    #3
  4. Zach

    santosh Guest

    stop wrote:

    >
    > "Zach" <> wrote in message
    >

    news:...
    >> On Mar 15, 8:09 pm, Richard Heathfield <> wrote:
    >>> Zach said:
    >>>
    >>> > I recall someone posting a website that had the complete K&R (2nd
    >>> > Ed. - ANSI) answers posted but I cannot find the post.
    >>>
    >>> Not complete (if I recall correctly) - but the Web site you're
    >>> looking for
    >>> is:
    >>>
    >>> <http://clc-wiki.net/wiki/K%26R2_solutions>

    >>
    >> Thanks Richard.


    > There's a worthwhile hard-copy available. _The C Solution Book_
    > About 3/8" thick and fewer errata than the covers of Unleashed.


    Do you mean /The C Answer Book/ by Clovis & Tondo?

    > I'm curious what's at that link.


    Solutions to some of the exercises in K&R2, contributed by various clc
    participants.
    santosh, Mar 16, 2008
    #4
  5. Zach

    stop Guest

    "Zach" <> wrote in message
    news:...
    > On Mar 15, 8:09 pm, Richard Heathfield <> wrote:
    >> Zach said:
    >>
    >> > I recall someone posting a website that had the complete K&R (2nd Ed.
    >> > - ANSI) answers posted but I cannot find the post.

    >>
    >> Not complete (if I recall correctly) - but the Web site you're looking
    >> for
    >> is:
    >>
    >> <http://clc-wiki.net/wiki/K%26R2_solutions>

    >
    > Thanks Richard.
    >
    > Zach

    There's a worthwhile hard-copy available. _The C Solution Book_ About 3/8"
    thick and fewer errata than the covers of Unleashed.

    I'm curious what's at that link.
    --
    "A man is accepted into church for what he believes--and turned out for
    what he knows."

    -Mark Twain
    stop, Mar 16, 2008
    #5
  6. Zach

    stop Guest

    "Richard Heathfield" <> wrote in message
    news:...
    > Zach said:
    >
    >> I recall someone posting a website that had the complete K&R (2nd Ed.
    >> - ANSI) answers posted but I cannot find the post.

    >
    > Not complete (if I recall correctly) - but the Web site you're looking for
    > is:
    >
    > <http://clc-wiki.net/wiki/K%26R2_solutions>


    I bookmarked the resource. It will save me occasionally from the abuse of
    having to straighten out my C syntax here.

    #from the site
    The folks in comp.lang.c may tend to come across as Standard-thumping
    fundamentalists, continuing to insist, with ramrod-straight demeanor, that
    all code be strictly conforming, as if it's only important for its own sake.
    But the insistence is not merely for its own sake: much more importantly,
    it's for the sake of code that's correct, not just in the ANSI C Standard
    sense, but in the much more important "works reliably in the real world"
    sense. As Steve Summit wrote on an occasion when this issue came up, "I'm
    not a Standard-thumping fundamentalist who worships at the altar of X3J11
    because I'm an anal-retentive dweeb who loves pouncing on people who
    innocently post code containing void main() to comp.lang.c; I'm a
    Standard-thumping fundamentalist who worships at the altar of X3J11 because
    it gives me eminently useful guarantees about the programs I write and helps
    me ensure that they'll work correctly next week and next month and next
    year, in environments I haven't heard of or can't imagine or that haven't
    been invented yet, and without continual hands-on bugfixing and coddling by
    me.
    #end excerpt

    Richard refers to the standard in the singular here. I think a lot of
    questions get caught in the crosshairs between standards. What catches my
    eye though is 3J as oppsoed to J3. Does X3J11 actually exist?

    --
    "A man is accepted into church for what he believes--and turned out for
    what he knows."

    -Mark Twain
    stop, Mar 16, 2008
    #6
  7. stop said:

    <snip>

    > #from the site [ <http://clc-wiki.net/wiki ]
    > The folks in comp.lang.c may tend to come across as Standard-thumping
    > fundamentalists, continuing to insist, with ramrod-straight demeanor,
    > that all code be strictly conforming, as if it's only important for its
    > own sake. But the insistence is not merely for its own sake: much more
    > importantly, it's for the sake of code that's correct, not just in the
    > ANSI C Standard sense, but in the much more important "works reliably in
    > the real world" sense. As Steve Summit wrote on an occasion when this
    > issue came up, "I'm not a Standard-thumping fundamentalist who worships
    > at the altar of X3J11 because I'm an anal-retentive dweeb who loves
    > pouncing on people who innocently post code containing void main() to
    > comp.lang.c; I'm a Standard-thumping fundamentalist who worships at the
    > altar of X3J11 because it gives me eminently useful guarantees about the
    > programs I write and helps me ensure that they'll work correctly next
    > week and next month and next year, in environments I haven't heard of or
    > can't imagine or that haven't been invented yet, and without continual
    > hands-on bugfixing and coddling by me.
    > #end excerpt
    >
    > Richard refers to the standard in the singular here.


    I don't remember writing the above, and I'm reasonably sure I /didn't/
    write the above. Any of it. The second half of it appears to have been
    written by Steve Summit (presumably in a Usenet article). And the first
    half? Well, I *might* have written it, but I don't think so.

    > What catches my eye though is 3J as oppsoed to J3. Does X3J11
    > actually exist?


    It certainly did, because it was the ANSI Committee that produced the C89
    Standard. Whether it still does, I have no idea.

    --
    Richard Heathfield <http://www.cpax.org.uk>
    Email: -http://www. +rjh@
    Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
    "Usenet is a strange place" - dmr 29 July 1999
    Richard Heathfield, Mar 16, 2008
    #7
  8. Zach wrote:
    > I recall someone posting a website that had the complete K&R (2nd Ed.
    > - ANSI) answers posted but I cannot find the post.



    Well about a K&R2 exercise posted in another thread. I think the answer:

    http://clc-wiki.net/wiki/K&R2_solutions:Chapter_2:Exercise_1

    #include <stdio.h>
    #include <limits.h>

    int
    main ()
    {
    printf("Size of Char %d\n", CHAR_BIT);
    printf("Size of Char Max %d\n", CHAR_MAX);
    printf("Size of Char Min %d\n", CHAR_MIN);
    printf("Size of int min %d\n", INT_MIN);
    printf("Size of int max %d\n", INT_MAX);
    printf("Size of long min %ld\n", LONG_MIN); /* RB */
    printf("Size of long max %ld\n", LONG_MAX); /* RB */
    printf("Size of short min %d\n", SHRT_MIN);
    printf("Size of short max %d\n", SHRT_MAX);
    printf("Size of unsigned char %u\n", UCHAR_MAX); /* SF */
    printf("Size of unsigned long %lu\n", ULONG_MAX); /* RB */
    printf("Size of unsigned int %u\n", UINT_MAX); /* RB */
    printf("Size of unsigned short %u\n", USHRT_MAX); /* SF */

    return 0;
    }


    is wrong and a bit incomplete.


    I think the correct one is:


    #include <stdio.h>
    #include <limits.h>

    int main ()
    {
    printf("Size of Char %d\n", CHAR_BIT);
    printf("Size of Char Max %d\n", CHAR_MAX);
    printf("Size of Char Min %d\n", CHAR_MIN);
    printf("Size of int min %d\n", INT_MIN);
    printf("Size of int max %d\n", INT_MAX);
    printf("Size of long min %ld\n", LONG_MIN); /* RB */
    printf("Size of long max %ld\n", LONG_MAX); /* RB */
    printf("Size of short min %d\n", SHRT_MIN);
    printf("Size of short max %d\n", SHRT_MAX);
    ==> printf("Size of unsigned char max %u\n", (unsigned) UCHAR_MAX);
    ==> printf("Size of unsigned long max %lu\n", ULONG_MAX); /* RB */
    ==> printf("Size of unsigned int max %u\n", UINT_MAX); /* RB */
    ==> printf("Size of unsigned short max %u\n", USHRT_MAX); /* SF */

    return 0;
    }
    Ioannis Vranos, Mar 16, 2008
    #8
  9. Ioannis Vranos wrote:
    > Zach wrote:
    >> I recall someone posting a website that had the complete K&R (2nd Ed.
    >> - ANSI) answers posted but I cannot find the post.

    >
    >
    > Well about a K&R2 exercise posted in another thread. I think the answer:
    >
    > http://clc-wiki.net/wiki/K&R2_solutions:Chapter_2:Exercise_1
    >
    > #include <stdio.h>
    > #include <limits.h>
    >
    > int
    > main ()
    > {
    > printf("Size of Char %d\n", CHAR_BIT);
    > printf("Size of Char Max %d\n", CHAR_MAX);
    > printf("Size of Char Min %d\n", CHAR_MIN);
    > printf("Size of int min %d\n", INT_MIN);
    > printf("Size of int max %d\n", INT_MAX);
    > printf("Size of long min %ld\n", LONG_MIN); /* RB */
    > printf("Size of long max %ld\n", LONG_MAX); /* RB */
    > printf("Size of short min %d\n", SHRT_MIN);
    > printf("Size of short max %d\n", SHRT_MAX);
    > printf("Size of unsigned char %u\n", UCHAR_MAX); /* SF */
    > printf("Size of unsigned long %lu\n", ULONG_MAX); /* RB */
    > printf("Size of unsigned int %u\n", UINT_MAX); /* RB */
    > printf("Size of unsigned short %u\n", USHRT_MAX); /* SF */
    >
    > return 0;
    > }
    >
    >
    > is wrong and a bit incomplete.
    >
    >
    > I think the correct one is:



    More:


    > #include <stdio.h>
    > #include <limits.h>
    >
    > int main ()
    > {

    ==> printf("Bits of Char %d\n", CHAR_BIT);
    > printf("Size of Char Max %d\n", CHAR_MAX);
    > printf("Size of Char Min %d\n", CHAR_MIN);
    > printf("Size of int min %d\n", INT_MIN);
    > printf("Size of int max %d\n", INT_MAX);
    > printf("Size of long min %ld\n", LONG_MIN); /* RB */
    > printf("Size of long max %ld\n", LONG_MAX); /* RB */
    > printf("Size of short min %d\n", SHRT_MIN);
    > printf("Size of short max %d\n", SHRT_MAX);
    > ==> printf("Size of unsigned char max %u\n", (unsigned) UCHAR_MAX);
    > ==> printf("Size of unsigned long max %lu\n", ULONG_MAX); /* RB */
    > ==> printf("Size of unsigned int max %u\n", UINT_MAX); /* RB */
    > ==> printf("Size of unsigned short max %u\n", USHRT_MAX); /* SF */
    >
    > return 0;
    > }
    Ioannis Vranos, Mar 16, 2008
    #9
  10. Ioannis Vranos said:

    <snip>
    >
    > Well about a K&R2 exercise posted in another thread. I think the answer:
    >
    > http://clc-wiki.net/wiki/K&R2_solutions:Chapter_2:Exercise_1
    >

    <snip>
    >
    > is wrong and a bit incomplete.


    Then why not submit your own version to the C wiki?

    --
    Richard Heathfield <http://www.cpax.org.uk>
    Email: -http://www. +rjh@
    Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
    "Usenet is a strange place" - dmr 29 July 1999
    Richard Heathfield, Mar 16, 2008
    #10
  11. Richard Heathfield wrote:
    > Ioannis Vranos said:
    >
    > <snip>
    >> Well about a K&R2 exercise posted in another thread. I think the answer:
    >>
    >> http://clc-wiki.net/wiki/K&R2_solutions:Chapter_2:Exercise_1
    >>

    > <snip>
    >> is wrong and a bit incomplete.

    >
    > Then why not submit your own version to the C wiki?



    I can't find out how to create an account.
    Ioannis Vranos, Mar 16, 2008
    #11
  12. Richard Heathfield wrote:
    >
    > Then why not submit your own version to the C wiki?



    OK, I edited the text.
    Ioannis Vranos, Mar 16, 2008
    #12
  13. Zach

    Flash Gordon Guest

    Ioannis Vranos wrote, On 16/03/08 15:45:
    > Richard Heathfield wrote:
    >> Ioannis Vranos said:
    >>
    >> <snip>
    >>> Well about a K&R2 exercise posted in another thread. I think the answer:
    >>>
    >>> http://clc-wiki.net/wiki/K&R2_solutions:Chapter_2:Exercise_1
    >>>

    >> <snip>
    >>> is wrong and a bit incomplete.

    >>
    >> Then why not submit your own version to the C wiki?

    >
    > I can't find out how to create an account.


    There is a box in the top right corner which when you hover the mouse
    over it will give you the login/creat account options. Alternatively
    alt+shift+O should work. Email me if you still have problems.
    --
    Flash Gordon
    Providing the server for the CLC Wiki
    Flash Gordon, Mar 16, 2008
    #13
  14. Ioannis Vranos <> writes:
    > Zach wrote:
    >> I recall someone posting a website that had the complete K&R (2nd Ed.
    >> - ANSI) answers posted but I cannot find the post.

    >
    > Well about a K&R2 exercise posted in another thread. I think the answer:
    >
    > http://clc-wiki.net/wiki/K&R2_solutions:Chapter_2:Exercise_1
    >
    > #include <stdio.h>
    > #include <limits.h>
    >
    > int
    > main ()
    > {
    > printf("Size of Char %d\n", CHAR_BIT);
    > printf("Size of Char Max %d\n", CHAR_MAX);
    > printf("Size of Char Min %d\n", CHAR_MIN);
    > printf("Size of int min %d\n", INT_MIN);
    > printf("Size of int max %d\n", INT_MAX);
    > printf("Size of long min %ld\n", LONG_MIN); /* RB */
    > printf("Size of long max %ld\n", LONG_MAX); /* RB */
    > printf("Size of short min %d\n", SHRT_MIN);
    > printf("Size of short max %d\n", SHRT_MAX);
    > printf("Size of unsigned char %u\n", UCHAR_MAX); /* SF */
    > printf("Size of unsigned long %lu\n", ULONG_MAX); /* RB */
    > printf("Size of unsigned int %u\n", UINT_MAX); /* RB */
    > printf("Size of unsigned short %u\n", USHRT_MAX); /* SF */
    >
    > return 0;
    > }
    >
    >
    > is wrong and a bit incomplete.
    >
    >
    > I think the correct one is:

    [snip]

    The more serious problem is that the messages are worded incorrectly.
    It prints, for example (on my system):

    Size of int max 2147483647

    2147483647 is not a size, it's an upper bound.

    The two lines
    printf("Size of int min %d\n", INT_MIN);
    printf("Size of int max %d\n", INT_MAX);
    should be replaced with something like:
    printf("Range of int is %d to %d\n", INT_MIN, INT_MAX);

    --
    Keith Thompson (The_Other_Keith) <>
    Nokia
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
    Keith Thompson, Mar 16, 2008
    #14
  15. Keith Thompson wrote:
    >
    > The more serious problem is that the messages are worded incorrectly.
    > It prints, for example (on my system):
    >
    > Size of int max 2147483647
    >
    > 2147483647 is not a size, it's an upper bound.
    >
    > The two lines
    > printf("Size of int min %d\n", INT_MIN);
    > printf("Size of int max %d\n", INT_MAX);
    > should be replaced with something like:
    > printf("Range of int is %d to %d\n", INT_MIN, INT_MAX);



    Fixed. I think your contribution is made clear in the text, if not
    please post a reply.
    Ioannis Vranos, Mar 16, 2008
    #15
  16. Zach

    santosh Guest

    Ioannis Vranos wrote:

    <snip code to print numerical limits>

    I also found the following in my archives. I remember that it was a
    bitch to type out. :)

    /* Program to print various implementation defined numerical limits.
    *
    * Set C99_CONFORMANCE to one if your compiler supports the features
    * needed by this program, but fails to define __STDC_VERSION to
    * 199901L.
    *
    * TODO: Include complex and imaginary types and features of the runtime
    * floating point environment through <fenv.h>
    */
    #define C99_CONFORMANCE 1
    #if __STDC_VERSION__ == 199901L || C99_CONFORMANCE == 1
    #define HAVE_C99 1
    #endif

    #include <stddef.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <limits.h>
    #include <float.h>
    #include <signal.h>
    #include <wchar.h>

    #ifdef HAVE_C99
    #include <inttypes.h>
    #include <stdbool.h>
    #endif

    int main(void)
    {
    int dummy;
    printf(
    "\nCHAR_BIT == %d\n\n"
    "Type\t\t\tSize\tMin.\t\t\tMax.\n"
    "============================================================\n\n"
    #if HAVE_C99 && __bool_true_false_are_defined
    "bool\t\t\t%u\n"
    #elif HAVE_C99
    "_Bool\t\t\t%u\n"
    #endif
    "char\t\t\t1\t%d\t\t\t%u\n"
    "signed char\t\t1\t%d\t\t\t%d\n"
    "unsigned char\t\t1\t0\t\t\t%u\n"
    "short\t\t\t%u\t%d\t\t\t%d\n"
    "unsigned short\t\t%u\t0\t\t\t%u\n"
    "int\t\t\t%u\t%d\t\t%d\n"
    "unsigned int\t\t%u\t0\t\t\t%u\n"
    "long\t\t\t%u\t%ld\t\t%ld\n"
    "unsigned long\t\t%u\t0\t\t\t%lu\n",
    CHAR_BIT,
    #if HAVE_C99 && __bool_true_false_are_defined
    (unsigned)sizeof(bool),
    #elif HAVE_C99
    (unsigned)sizeof(_Bool),
    #endif
    CHAR_MIN, CHAR_MAX,
    SCHAR_MIN, SCHAR_MAX,
    UCHAR_MAX,
    (unsigned)sizeof(short), SHRT_MIN, SHRT_MAX,
    (unsigned)sizeof(unsigned short), USHRT_MAX,
    (unsigned)sizeof(int), INT_MIN, INT_MAX,
    (unsigned)sizeof(unsigned int), UINT_MAX,
    (unsigned)sizeof(long), LONG_MIN, LONG_MAX,
    (unsigned)sizeof(unsigned long), ULONG_MAX);
    #ifdef HAVE_C99
    printf(
    "long long\t\t%u\t%lld\t%lld\n"
    "unsigned long long\t%u\t0\t\t\t%llu\n",
    (unsigned)sizeof(long long), LLONG_MIN, LLONG_MAX,
    (unsigned)sizeof(unsigned long long), ULLONG_MAX);
    #endif
    printf(
    "float\t\t\t%u\t%g\t\t%g\n"
    "double\t\t\t%u\t%g\t\t%g\n"
    "long double\t\t%u\t%Lg\t\t%Lg\n",
    (unsigned)sizeof(float), FLT_MIN, FLT_MAX,
    (unsigned)sizeof(double), DBL_MIN, DBL_MAX,
    (unsigned)sizeof(long double), LDBL_MIN, LDBL_MAX);
    printf(
    "\nAdditional properties of floating types:\n"
    "FLT_RADIX\t\t%d\n"
    "FLT_MANT_DIG\t\t%d\n"
    "DBL_MANT_DIG\t\t%d\n"
    "LDBL_MANT_DIG\t\t%d\n"
    #ifdef HAVE_C99
    "DECIMAL_DIG\t\t%d\n"
    #endif
    "FLT_DIG\t\t\t%d\n"
    "DBL_DIG\t\t\t%d\n"
    "LDBL_DIG\t\t%d\n"
    "FLT_MIN_EXP\t\t%d\n"
    "FLT_MAX_EXP\t\t%d\n"
    "DBL_MIN_EXP\t\t%d\n"
    "DBL_MAX_EXP\t\t%d\n"
    "LDBL_MIN_EXP\t\t%d\n"
    "LDBL_MAX_EXP\t\t%d\n"
    "FLT_MIN_10_EXP\t\t%d\n"
    "FLT_MAX_10_EXP\t\t%d\n"
    "DBL_MIN_10_EXP\t\t%d\n"
    "DBL_MAX_10_EXP\t\t%d\n"
    "LDBL_MIN_10_EXP\t\t%d\n"
    "LDBL_MAX_10_EXP\t\t%d\n"
    "FLT_EPSILON\t\t%g\n"
    "DBL_EPSILON\t\t%g\n"
    "LDBL_EPSILON\t\t%Lg\n",
    FLT_RADIX, FLT_MANT_DIG, DBL_MANT_DIG, LDBL_MANT_DIG,
    #ifdef HAVE_C99
    DECIMAL_DIG,
    #endif
    FLT_DIG, DBL_DIG, LDBL_DIG, FLT_MIN_EXP, FLT_MAX_EXP,
    DBL_MIN_EXP,
    DBL_MAX_EXP, LDBL_MIN_EXP, LDBL_MAX_EXP, FLT_MIN_10_EXP,
    FLT_MAX_10_EXP, DBL_MIN_10_EXP, DBL_MAX_10_EXP, LDBL_MIN_10_EXP,
    LDBL_MAX_10_EXP, FLT_EPSILON, DBL_EPSILON, LDBL_EPSILON);

    #ifdef HAVE_C99
    printf(
    "\nProperties of types defined in stdint.h\n"
    #ifdef INT8_MIN
    "int8_t\t\t\t%u\t%" PRId8 "\t\t\t%" PRId8 "\n"
    "uint8_t\t\t\t%u\t0\t\t\t%" PRIu8 "\n"
    #endif
    #ifdef INT16_MIN
    "int16_t\t\t\t%u\t%" PRId16 "\t\t\t%" PRId16 "\n"
    "uint16_t\t\t%u\t0\t\t\t%" PRIu16 "\n"
    #endif
    #ifdef INT32_MIN
    "int32_t\t\t\t%u\t%" PRId32 "\t\t%" PRId32 "\n"
    "uint32_t\t\t%u\t0\t\t\t%" PRIu32 "\n"
    #endif
    #ifdef INT64_MIN
    "int64_t\t\t\t%u\t%" PRId64 "\t%" PRId64 "\n"
    "uint64_t\t\t%u\t0\t\t\t%" PRIu64 "\n"
    #endif
    "int_least8_t\t\t%u\t%" PRIdLEAST8 "\t\t\t%" PRIdLEAST8 "\n"
    "uint_least8_t\t\t%u\t0\t\t\t%" PRIuLEAST8 "\n"
    "int_least16_t\t\t%u\t%" PRIdLEAST16 "\t\t\t%" PRIdLEAST16 "\n"
    "uint_least16_t\t\t%u\t0\t\t\t%" PRIuLEAST16 "\n"
    "int_least32_t\t\t%u\t%" PRIdLEAST32 "\t\t%" PRIdLEAST32 "\n"
    "uint_least32_t\t\t%u\t0\t\t\t%" PRIuLEAST32 "\n"
    "int_least64_t\t\t%u\t%" PRIdLEAST64 "\t%" PRIdLEAST64 "\n"
    "uint_least64_t\t\t%u\t0\t\t\t%" PRIuLEAST64 "\n"
    "int_fast8_t\t\t%u\t%" PRIdFAST8 "\t\t\t%" PRIdFAST8 "\n"
    "uint_fast8_t\t\t%u\t0\t\t\t%" PRIuFAST8 "\n"
    "int_fast16_t\t\t%u\t%" PRIdFAST16 "\t\t%" PRIdFAST16 "\n"
    "uint_fast16_t\t\t%u\t0\t\t\t%" PRIuFAST16 "\n"
    "int_fast32_t\t\t%u\t%" PRIdFAST32 "\t\t%" PRIdFAST32 "\n"
    "uint_fast32_t\t\t%u\t0\t\t\t%" PRIuFAST32 "\n"
    "int_fast64_t\t\t%u\t%" PRIdFAST64 "\t%" PRIdFAST64 "\n"
    "uint_fast64_t\t\t%u\t0\t\t\t%" PRIuFAST64 "\n"
    "intmax_t\t\t%u\t%" PRIdMAX "\t%" PRIdMAX "\n"
    "uintmax_t\t\t%u\t0\t\t\t%" PRIuMAX "\n"
    #ifdef INTPTR_MIN
    "intptr_t\t\t%u\t%" PRIdPTR "\t\t%" PRIdPTR "\n"
    #endif
    #ifdef UINTPTR_MAX
    "uintptr_t\t\t%u\t0\t\t\t%" PRIuPTR "\n"
    #endif
    "%n"
    ,
    #ifdef INT8_MIN
    (unsigned)sizeof(int8_t), INT8_MIN, INT8_MAX,
    (unsigned)sizeof(uint8_t), UINT8_MAX,
    #endif
    #ifdef INT16_MIN
    (unsigned)sizeof(int16_t), INT16_MIN, INT16_MAX,
    (unsigned)sizeof(uint16_t), UINT16_MAX,
    #endif
    #ifdef INT32_MIN
    (unsigned)sizeof(int32_t), INT32_MIN, INT32_MAX,
    (unsigned)sizeof(uint32_t), UINT32_MAX,
    #endif
    #ifdef INT64_MIN
    (unsigned)sizeof(int64_t), INT64_MIN, INT64_MAX,
    (unsigned)sizeof(uint64_t), UINT64_MAX,
    #endif
    (unsigned)sizeof(int_least8_t), INT_LEAST8_MIN, INT_LEAST8_MAX,
    (unsigned)sizeof(uint_least8_t), UINT_LEAST8_MAX,
    (unsigned)sizeof(int_least16_t), INT_LEAST16_MIN,
    INT_LEAST16_MAX,
    (unsigned)sizeof(uint_least16_t), UINT_LEAST16_MAX,
    (unsigned)sizeof(int_least32_t), INT_LEAST32_MIN,
    INT_LEAST32_MAX,
    (unsigned)sizeof(uint_least32_t), UINT_LEAST32_MAX,
    (unsigned)sizeof(int_least64_t), INT_LEAST64_MIN,
    INT_LEAST64_MAX,
    (unsigned)sizeof(uint_least64_t), UINT_LEAST64_MAX,
    (unsigned)sizeof(int_fast8_t), INT_FAST8_MIN, INT_FAST8_MAX,
    (unsigned)sizeof(uint_fast8_t), UINT_FAST8_MAX,
    (unsigned)sizeof(int_fast16_t), INT_FAST16_MIN, INT_FAST16_MAX,
    (unsigned)sizeof(uint_fast16_t), UINT_FAST16_MAX,
    (unsigned)sizeof(int_fast32_t), INT_FAST32_MIN, INT_FAST32_MAX,
    (unsigned)sizeof(uint_fast32_t), UINT_FAST32_MAX,
    (unsigned)sizeof(int_fast64_t), INT_FAST64_MIN, INT_FAST64_MAX,
    (unsigned)sizeof(uint_fast64_t), UINT_FAST64_MAX,
    (unsigned)sizeof(intmax_t), INTMAX_MIN, INTMAX_MAX,
    (unsigned)sizeof(uintmax_t), UINTMAX_MAX,
    #ifdef INTPTR_MIN
    (unsigned)sizeof(intptr_t), INTPTR_MIN, INTPTR_MAX,
    #endif
    #ifdef UINTPTR_MAX
    (unsigned)sizeof(uintptr_t), UINTPTR_MAX,
    #endif
    &dummy);
    #endif

    printf(
    "\nOther types:\n"
    "ptrdiff_t\t\t%u"
    #ifdef PTRDIFF_MIN
    "\t%td\t\t%td"
    #endif
    "\n"
    "size_t\t\t\t%u\t0\t\t\t%lu\n"
    #ifdef WCHAR_MIN
    "wchar_t\t\t\t%u\t%ld\t\t%lu\n"
    #endif
    #ifdef WINT_MIN
    "wint_t\t\t\t%u\t%d\t\t\t%u\n"
    #endif
    "sig_atomic_t\t\t%u"
    #ifdef SIG_ATOMIC_MIN
    "\t%d\t\t%u"
    #endif
    "\n"

    "BUFSIZ\t\t\t%lu\n"
    "FOPEN_MAX\t\t%u\n"
    "FILENAME_MAX\t\t%u\n"
    "L_tmpnam\t\t%u\n"
    "TMP_MAX\t\t\t%lu\n"
    "RAND_MAX\t\t%lu\n"
    "MB_LEN_MAX\t\t%lu\n"
    "MB_CUR_MAX\t\t%lu\n"
    "%n",
    (unsigned)sizeof(ptrdiff_t),
    #ifdef PTRDIFF_MIN
    PTRDIFF_MIN, PTRDIFF_MAX,
    #endif
    (unsigned)sizeof(size_t), (unsigned long)((size_t)-1),
    #ifdef WCHAR_MIN
    (unsigned)sizeof(wchar_t), WCHAR_MIN, WCHAR_MAX,
    #endif
    #ifdef WINT_MIN
    (unsigned)sizeof(wint_t), WINT_MIN, WINT_MAX,
    #endif
    (unsigned)sizeof(sig_atomic_t),
    #ifdef SIG_ATOMIC_MIN
    SIG_ATOMIC_MIN, SIG_ATOMIC_MAX,
    #endif
    (unsigned long)BUFSIZ, FOPEN_MAX, FILENAME_MAX, L_tmpnam,
    (unsigned long)TMP_MAX, (unsigned long)RAND_MAX,
    (unsigned long)MB_LEN_MAX, (unsigned long)MB_CUR_MAX, &dummy);

    return 0;
    }
    santosh, Mar 16, 2008
    #16
  17. Zach

    stop Guest

    "Richard Heathfield" <> wrote in message
    news:...
    > stop said:
    >
    > <snip>
    >
    >> #from the site [ <http://clc-wiki.net/wiki ]
    >> The folks in comp.lang.c may tend to come across as Standard-thumping
    >> fundamentalists, continuing to insist, with ramrod-straight demeanor,
    >> that all code be strictly conforming, as if it's only important for its
    >> own sake. But the insistence is not merely for its own sake: much more
    >> importantly, it's for the sake of code that's correct, not just in the
    >> ANSI C Standard sense, but in the much more important "works reliably in
    >> the real world" sense. As Steve Summit wrote on an occasion when this
    >> issue came up, "I'm not a Standard-thumping fundamentalist who worships
    >> at the altar of X3J11 because I'm an anal-retentive dweeb who loves
    >> pouncing on people who innocently post code containing void main() to
    >> comp.lang.c; I'm a Standard-thumping fundamentalist who worships at the
    >> altar of X3J11 because it gives me eminently useful guarantees about the
    >> programs I write and helps me ensure that they'll work correctly next
    >> week and next month and next year, in environments I haven't heard of or
    >> can't imagine or that haven't been invented yet, and without continual
    >> hands-on bugfixing and coddling by me.
    >> #end excerpt
    >>
    >> Richard refers to the standard in the singular here.

    >
    > I don't remember writing the above, and I'm reasonably sure I /didn't/
    > write the above. Any of it. The second half of it appears to have been
    > written by Steve Summit (presumably in a Usenet article). And the first
    > half? Well, I *might* have written it, but I don't think so.

    Reading was never your strong suit. The text does sound like you but looks
    like it may have been pasted together.


    >> What catches my eye though is 3J as oppsoed to J3. Does X3J11
    >> actually exist?

    >
    > It certainly did, because it was the ANSI Committee that produced the C89
    > Standard. Whether it still does, I have no idea.

    In the common C extension that is fortran, the J3 committee is kind of like
    a benevolent politburo. I never saw anything that might motivate the name
    except to see the letters reversed in X3J11.

    --
    "A man is accepted into church for what he believes--and turned out for
    what he knows."

    -Mark Twain
    stop, Mar 17, 2008
    #17
  18. Zach

    stop Guest

    "santosh" <> wrote in message
    news:fri6kr$n8n$...
    > stop wrote:
    >
    >>
    >> "Zach" <> wrote in message
    >>

    > news:...
    >>> On Mar 15, 8:09 pm, Richard Heathfield <> wrote:
    >>>> Zach said:
    >>>>
    >>>> > I recall someone posting a website that had the complete K&R (2nd
    >>>> > Ed. - ANSI) answers posted but I cannot find the post.
    >>>>
    >>>> Not complete (if I recall correctly) - but the Web site you're
    >>>> looking for
    >>>> is:
    >>>>
    >>>> <http://clc-wiki.net/wiki/K%26R2_solutions>
    >>>
    >>> Thanks Richard.

    >
    >> There's a worthwhile hard-copy available. _The C Solution Book_
    >> About 3/8" thick and fewer errata than the covers of Unleashed.

    >
    > Do you mean /The C Answer Book/ by Clovis & Tondo?

    Yup. I dug it out today while I was moving crates of books. It's more like
    5/8".

    The authors are Tondo and Gimpel. Mr. Tondo's first name is Clovis. I'm
    reasonably certain I've never met a Clovis before.

    --
    "A man is accepted into church for what he believes--and turned out for
    what he knows."

    -Mark Twain
    stop, Mar 17, 2008
    #18
  19. "stop" <> writes:
    > "Richard Heathfield" <> wrote in message
    > news:...
    >> stop said (quoting somebody else):

    [snip]
    >>> As Steve Summit wrote on an occasion when this
    >>> issue came up, "I'm not a Standard-thumping fundamentalist who worships
    >>> at the altar of X3J11 because I'm an anal-retentive dweeb who loves
    >>> pouncing on people who innocently post code containing void main() to
    >>> comp.lang.c; I'm a Standard-thumping fundamentalist who worships at the
    >>> altar of X3J11 because it gives me eminently useful guarantees about the
    >>> programs I write and helps me ensure that they'll work correctly next
    >>> week and next month and next year, in environments I haven't heard of or
    >>> can't imagine or that haven't been invented yet, and without continual
    >>> hands-on bugfixing and coddling by me.

    [snip]
    >>> What catches my eye though is 3J as oppsoed to J3. Does X3J11
    >>> actually exist?

    >>
    >> It certainly did, because it was the ANSI Committee that produced the C89
    >> Standard. Whether it still does, I have no idea.

    > In the common C extension that is fortran, the J3 committee is kind of like
    > a benevolent politburo. I never saw anything that might motivate the name
    > except to see the letters reversed in X3J11.


    X3 is the former name for INCITS, the InterNational Committee for
    Information Technology Standards; see <http://www.x3.org/>.

    Within X3, J3 (or X3J3) is the Technical Committee for Fortran, and
    J11 (or X3J11) is the Tehnical Committee for C; see
    <http://www.incits.org>.

    One source says that X3J11 was originally formed by ANSI. I'm not
    sure of the current relationship between ANSI and INCITS, or of the
    organizational history.

    I suggest that a quick Google search for "X3J11" would have cleared up
    your confusion.

    --
    Keith Thompson (The_Other_Keith) <>
    Nokia
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
    Keith Thompson, Mar 17, 2008
    #19
  20. Zach

    santosh Guest

    stop wrote:
    > "santosh" <> wrote in message
    > news:fri6kr$n8n$...


    <snip>

    >> Do you mean /The C Answer Book/ by Clovis & Tondo?

    > Yup. I dug it out today while I was moving crates of books. It's
    > more like 5/8".
    >
    > The authors are Tondo and Gimpel. Mr. Tondo's first name is Clovis.
    > I'm reasonably certain I've never met a Clovis before.


    You are right, thanks.
    santosh, Mar 18, 2008
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Big E

    Multiple answers for parameters

    Big E, Jul 2, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    300
    Big E
    Jul 2, 2004
  2. Tina

    PrepLogic bogus Answers

    Tina, Oct 11, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    361
    clintonG
    Oct 12, 2004
  3. Juan T. Llibre
    Replies:
    4
    Views:
    294
    =?Utf-8?B?dmluYXk=?=
    Jan 14, 2005
  4. A Fan
    Replies:
    8
    Views:
    291
    Michael Borgwardt
    Oct 22, 2003
  5. Xano

    Count Answers

    Xano, Apr 12, 2004, in forum: Java
    Replies:
    1
    Views:
    407
    =?UTF-8?b?TMSByrtpZSBUZWNoaWU=?=
    Apr 12, 2004
Loading...

Share This Page