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

Pages: 1-

How does this work?

Name: Anonymous 2013-02-05 12:28


#include <stdio.h>

int main ()
{
    int c, d;

    d = EOF;

    while ((c = getchar()) != EOF){
        if (c == ' ')
            if (c != d)
                putchar(' ');
        else
            putchar(c);
    }
}

Name: Anonymous 2013-02-05 12:31

forgot the return 0.

Name: Anonymous 2013-02-05 12:53

it doesn't

Name: Anonymous 2013-02-05 13:00

>>1
Here's an idea:

#include <stdio.h>
int main(void) { int c; while ((c = getchar()) != EOF) putchar(c); return 0; }


It does the same thing.

Name: Anonymous 2013-02-05 13:10

>>1
How does this work?
like shit

Name: Anonymous 2013-02-05 13:51

>>3
But it does.
>>4
Nope.

It doesn't remove the trailing blanks.

Name: Anonymous 2013-02-05 13:52

OP here, I fucked up some parts:
[code]
#include <stdio.h>

int main ()
{
    int c, d;

    d = EOF;

    while ((c = getchar()) != EOF){
        if (c == ' ')
            if (c != d)
                putchar(' ');
        else
            putchar(c);
        d = c;
    }
    return 0;
}

Name: Anonymous 2013-02-05 13:56

Your indentation is shit. That else seems silly now. Or maybe it's on purpose that way... retarded shit.

Name: Anonymous 2013-02-05 14:04

>>8
Your indentation is shit.
Why?
Or maybe it's on purpose that way... retarded shit.
Why is it retarded?
the else is the same as writing if (c != ' ').

Name: Anonymous 2013-02-05 14:04

>>8
Your indentation is shit.
Why?
Or maybe it's on purpose that way... retarded shit.
Why is it retarded?
the else is the same as writing if (c != ' ').

Name: Anonymous 2013-02-05 14:07

Oh shit, posting on a phone sucks.

Name: Anonymous 2013-02-05 16:59

>>11
yes it sucks
don't do that

Name: Anonymous 2013-02-05 17:06

Oh shit, posting on  /prog/ sucks.

Name: Anonymous 2013-02-05 17:57

I had trouble with this exercise in K&R. Took me forever to realise I had the ifs mixed up, so it ended up emovingetterikehis

Name: Anonymous 2013-02-05 18:25

>>14
LLLLLEEEEEEEEEEEEEEEEEEEEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLLLL
>EGIN LE SAGE!
>EGINGOINGWINZIMSIN GRO!!!!! XDDDDD

Name: Anonymous 2013-02-05 20:21

>>15
LLLLLEEEEEEEEEEEEEEEEEEEEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLLLL
>EGIN LE BRAIN DISEASE!
>EGINGOINGWINZIMSIN GRO!!!!! XDDDDD

Name: Anonymous 2013-02-05 20:22

>>16
LLLLLEEEEEEEEEEEEEEEEEEEEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLLLL
>EGIN LE SAGE!
>EGINGOINGWINZIMSIN GRO!!!!! XDDDDD

Name: Anonymous 2013-02-05 20:54

>>17
LLLLLEEEEEEEEEEEEEEEEEEEEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLLLL
>EGIN LE BRAIN DISEASE!
>EGINGOINGWINZIMSIN GRO!!!!! XDDDDD

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