Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

C Standard Library oddity

Name: Anonymous 2008-06-25 9:12

int fputc(int c, FILE *stream);

So why does fputc take an integer when it writes an unsigned char?
Believe it or not, I actually had a fucked up program because of this and it took so long to get it right because I couldn't understand what was wrong.

Name: Anonymous 2008-06-25 9:32

▄▀▀▀▀▀▀▀█████▄ ▀▀▀▀▀██████▄ ▀▀█████▄ ▀▀▀▀▀▀█████████▄ ██▄  ▄▀▀████▄
█         ▀▌▀██       ▐▀ ▀███  ▐▀ ▀██        ▀▌ ▀▀████  ██  █  ▐ ▀██
█            ▐█    ▄▄     ▀██      ▐█              ▀▐█  ▐█  █     ▐█
▓       ▄▄▄▄▄▄▀   █  █     ▐▓       ▓ ▄▄        ▄▄▄▄▄▀   █  █      ▓
▒      █          ▀▀▀▀      ▒       ▒   ▒      ▒  ▄       ▀▀       ▒
░       ▀▀▀▀▄               ░       ░   ░      ░  ░                ░
░           ▀      ▄▄       ░       ░   ░      ░  ░       ▄▄       ░
░      ▄▀▀▀▀      █  █      ░       ░   ░      ░  ░      ░  ░      ░
▒░    ░▓   ░░    ░█  █░    ░▒      ░▒   ▒░    ░▒  ▒░    ░▒  ▒░    ░▒
▓▒░  ░▒▒   ▒▒░  ░▒█  █▒░  ░▒▓     ░▒▓   ▓▒░  ░▒▓  ▓▒░  ░▒▓  ▓▒░  ░▒▓
█▓▒░░▒▓▓   ▓▓▒░░▒▓█  █▓▒░░▒▓█    ░▒▓█   █▓▒░░▒▓█  █▓▒░░▒▓█  █▓▒░░▒▓█
 ▀▀▀▀▀▀     ▀▀▀▀▀▀    ▀▀▀▀▀▀  ▀▀▀▀▀▀     ▀▀▀▀▀▀    ▀▀▀▀▀▀    ▀▀▀▀▀▀

Name: Anonymous 2008-06-25 9:44

It's for type compatibility with getchar, which returns an int rather than unsigned char so it can include negative numbers for exceptions like EOF.

Name: Anonymous 2008-06-25 9:46

Compatibility with getc, I mean.

Name: Anonymous 2008-06-25 9:50

▄▀▀▀▀▀▀▀█████▄ ▀▀▀▀▀██████▄ ▀▀█████▄ ▀▀▀▀▀▀█████████▄ ██▄  ▄▀▀████▄
█         ▀▌▀██       ▐▀ ▀███  ▐▀ ▀██        ▀▌ ▀▀████  ██  █  ▐ ▀██
█            ▐█    ▄▄     ▀██      ▐█              ▀▐█  ▐█  █     ▐█
▓       ▄▄▄▄▄▄▀   █  █     ▐▓       ▓ ▄▄        ▄▄▄▄▄▀   █  █      ▓
▒      █          ▀▀▀▀      ▒       ▒   ▒      ▒  ▄       ▀▀       ▒
░       ▀▀▀▀▄               ░       ░   ░      ░  ░                ░
░           ▀      ▄▄       ░       ░   ░      ░  ░       ▄▄       ░
░      ▄▀▀▀▀      █  █      ░       ░   ░      ░  ░      ░  ░      ░
▒░    ░▓   ░░    ░█  █░    ░▒      ░▒   ▒░    ░▒  ▒░    ░▒  ▒░    ░▒
▓▒░  ░▒▒   ▒▒░  ░▒█  █▒░  ░▒▓     ░▒▓   ▓▒░  ░▒▓  ▓▒░  ░▒▓  ▓▒░  ░▒▓
█▓▒░░▒▓▓   ▓▓▒░░▒▓█  █▓▒░░▒▓█    ░▒▓█   █▓▒░░▒▓█  █▓▒░░▒▓█  █▓▒░░▒▓█
 ▀▀▀▀▀▀     ▀▀▀▀▀▀    ▀▀▀▀▀▀  ▀▀▀▀▀▀     ▀▀▀▀▀▀    ▀▀▀▀▀▀    ▀▀▀▀▀▀

Name: Anonymous 2008-06-25 10:23

>>5
Ar good idea, its probs gona butcher it but i wana get it done lol

Name: Anonymous 2008-06-25 10:40

       ,'``.._   ,'``.
      :,--._:)\,:,._,.:      
      :`~-,''   :`.~.';\        HAVE YOU READ
       `,'       `---'  `.     YOUR SICP TODAY?
       /                 :
      /                   \
    ,'                     :\.___,-.
   `...,---'``````-..._    |:       \
     (                 )   ;:    )   \  _,-.
      `.              (   //          `'    \
       :               `.//  )      )     , ;
     ,-|`.            _,'/       )    ) ,' ,'
    (  :`.`-..____..=:.-':     .     _,' ,'
     `,'\ ``--....-)='    `._,  \  ,') _ '``._
  _.-/ _ `.       (_)      /     )' ; / \ \`-.'
 `--(   `-:`.     `' ___..'  _,-'   |/   `.)
     `-. `.`.``-----``--,  .'
       |/`.\`'        ,',');

Name: Anonymous 2008-06-25 10:48

'-._                  ___.....___                           ___,,,,,___                  _,-'
    `.__           ,-'        ,-.`-,                     .-`,-.        '-.           __,`
        `''-------'          ( p )  `._               _,`  ( q )          '-------''`
                              `-'      \             /      '-`
                                        \           /
                              .         \           /         ,
                               \---..,--'           '--.,,---/
   ................._           --...--,             .--,,,--           _,,,,,,,,,,,,,,,,,
                     `-.._         _.-'               '-,_         _,,-`
                          `'-----''                       ''-----'`

Name: Anonymous 2008-06-25 11:01


                            .
                                      @
                       @      \   ,
                                    /          ,'``.._   ,'``.
                         \   .                :,--._:)\,:,._,.:
                                ,      ,      :`~-,''   :`.~.';\
'-._                  ___.....___     /        `,'       `---'  `.
    `.__           ,-'        \-/`-,           /                 :
        `''-------'          ( @ )  `._       /                   \
                              >->      \    ,'                     :\.___,-.
                                        \  `...,---'``````-..._    |:       \
                              .         \    (                 )   ;:    )   \  _,-.
                               \---..,--'     `.              (   //          `'    \
   ................._           \,'..--,       :               `.//  )      )     , ;
                     `-.._       ||_.-'      ,-|`.            _,'/       )    ) ,' ,'
                          `'-----''         (  :`.`-..____..=:.-':     .     _,' ,'
                                 ||          `,'\ ``--....-)='    `._,  \  ,') _ '``._
                                 ||       _.-/ _ `.       (_)      /     )' ; / \ \`-.'
                                 /\      `--(   `-:`.     `' ___..'  _,-'   |/   `.)
                                             `-. `.`.``-----``--,  .'
                                               |/`.\`'        ,',');

Name: Anonymous 2008-06-25 15:24

Name: Anonymous 2008-06-26 6:39

protip: >>10 is 'hyryst', that reddit faggot.
>>1
what was your fucked up program? how was it fucked up?
Till you post about it, I'll assert that >>1-10 is the same faggot.

Name: Anonymous 2008-06-26 7:33

>>3,4,7,9,10,12
Same person

Name: Anonymous 2008-06-26 14:16

You're all wrong.
If you check all the standard C functions, you'll notice there isn't a single one that takes 'char' as an argument; back in the day compilers had a difficult job to do with those hz, so the type promotions (which all become int, unless the type is not capable of representing the value) had to be as fit as possible.
Thus, int even when char was meant.
A better example is strchr.

Name: Anonymous 2010-12-17 1:36

Are you GAY?
Are you a NIGGER?
Are you a GAY NIGGER?

If you answered "Yes" to all of the above questions, then GNAA (GAY NIGGER ASSOCIATION OF AMERICA) might be exactly what you've been looking for!

Name: Anonymous 2010-12-23 6:20

Name: Anonymous 2011-02-04 19:55

Name: Sgt.Kabukiman뜚ꥱ 2012-05-24 9:38

All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy

Name: bampu pantsu 2012-05-29 3:58

bampu pantsu

Don't change these.
Name: Email:
Entire Thread Thread List