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

Pages: 1-

C binary

Name: Anonymous 2007-02-06 9:43

#include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 
 int main(int argc, char **argv) {
    
     int i, loop, arguments = 0;
     char c, temp, binary[8];
    
     if(argc == 1) {
         fprintf(stderr, "Usage: %s [string]\n", argv[0]);
         return 1;
     }
    
     while(++arguments < argc)
         for(i=0; i< strlen(argv[arguments]); i++) {
             c = argv[arguments][i];
             loop = -1;
            
             while(++loop-8) {
                 binary[7 - loop] = (48 + c%2);
                 c /= 2;
             }
             (i+1)%4?fputs(binary, stdout):puts(binary);
         }
    
     return 0;
 }

Name: Anonymous 2007-02-06 11:48

>>1
*bashes shitty C* ;)

Name: Anonymous 2007-02-09 10:59

>>2
this man DOESN'T KNOW what he's talking about

Name: Anonymous 2007-02-09 12:00

That code IS truly revolting.

Name: Anonymous 2007-02-09 12:02

>>1
One word, the voluntary indentation of code. Thread over.

Name: Anonymous 2007-02-10 2:36 (sage)

Well there is the use of the ?: construct where more properly an if()-else would've made more sense. Also, puts(x) and fputs(x, stdout) are exactly equivalent.

Name: Anonymous 2007-02-10 12:06

>>6
OP here
puts and fputs aren't equivalent.
puts forces a newline, fputs doesn't.
i made it so every 4*8 numbers it puts a newline.
Maybe you should compile&run a script (and also look at the reference) before posting.

Name: Anonymous 2007-02-10 12:33

>>7
Your code reminded me why trying to do binary without BINARY OPERATORS really fails hard.

Name: Anonymous 2007-02-10 15:08

>>7
Your code reminded me why I hate niggers.

Name: Anonymous 2007-02-10 15:17

>>7
your code reinvented a sperm receptacle

Name: Anonymous 2007-02-10 15:25

>>7
Your code caused me to ejaculate prematurely.

Name: Anonymous 2007-02-10 15:53

>>11
me 2

Name: Anonymous 2009-01-14 15:02

THIS IS MADNESS

Name: Anonymous 2010-06-25 14:46

WARNING: NECRO POST

Name: ​​​​​​​​​​ 2010-09-09 16:48

Name: Anonymous 2011-02-04 17:42

Name: Sgt.Kabu꽹뚏kiman廵Ἱ 2012-05-28 22:19

Bringing /prog/ back to its people
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy

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