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

[C] post your gets()

Name: Anonymous 2013-03-14 2:49

As we know, gets() is unsafe, fgets() annoyingly retains the '\n', getline() is non-standard, and scanf() always stops at spaces.  Many of us wind up rolling our own.

This one
1. always NUL-terminates
2. is efficient since there are only two tests in the main loop
3. discards everything until the end of the line if truncation occurs.

void
getstr(char *s, size_t siz)
{
        int     c;
        char    *max = s + siz - 1;

        while ((c = getchar()) != '\n' && s < max)
                *s++ = c;
        *s = '\0';
        while (c != '\n')
                c = getchar();
}

Name: Anonymous 2013-03-15 1:16

>>35
AINT RED DA STANDARD ON STRINGS EIDER

Name: Anonymous 2013-03-15 1:22

>>40,41
Right in the standard!

Name: Lambda Arthur Calculus 2013-03-15 1:36

>>35
Yaint thought bout wat happens wen fgets fills ur lil buffer with "\n". Aint gonna give ya an empty string, strtok. Not once, not twice, n certainly not thrice.
>>34
Yaint thought bout wat a string is.

I was da guy who wrote strcspn n strtok. I kno wats wat. Though I didnt write fgets tho, dat was deanis. FUCKING POPPAVIC ATE HIS FUCKING CORPSE, THAT CANNIBAL.

Name: 43 2013-03-15 1:42

FUK I CONFUSED >>35 WITH >>34. EEEEEEEEEEEH EEEEEEEEEEEEEEEEEEH EEEEEEEEEEEEEEEEEEEEEH EEEEEEEEEEEEEEEEEEEEEEEEEEEEEH!!!!!!

Name: Anonymous 2013-03-15 1:44

cant believe dem ISO bastards threw me off da fuckin committee ...

Name: Anonymous 2013-03-15 1:49

I bet he's one of dem ISO-preaching hyenas, fuckin poppavic. wasn't enough 2 trash the language he loved, had to eat the poor guy's corpse too.

rsize_t -- wat da fuk is dat? aint seen stupid shit like dat back in C89.

Name: Anonymous 2013-03-15 2:46

woof it up sunday

Name: Anonymous 2013-03-15 3:47

My first reaction to rsize_t is oh boy! What's that! I can't wait to find out! Is it too late for me? Is this really the person I have become?

Name: Anonymous 2013-03-15 4:32

>>48
no more funnies!!!

Name: Anonymous 2013-03-15 4:37

a = gets
:3

Name: JAVA PROGRAMMER 2013-03-15 12:27

In the past I had to tell the compiler I needed some space for a structure. Terrible, because the compiler knows anything about the structure. Then I saw, this was because I created the struct dynamically.
C is a dynamic programming language, so the compiler cannot know the size of the structure in advance! Then I made a preprocessor, which transformed the structures in a const string and cast them to the structure I needed. I had created immutable data structures. So much fun I had. I could transform code in a static circuit! I never had segmentation faults, buffer overflows or other dynamic problems again.

Name: Anonymous 2013-03-15 15:27

Doesn't work on Microsoft Wisdom 7

Name: Anonymous 2013-03-15 19:33

wamper arter cack your ass

Name: Anonymous 2013-03-15 21:52

fread

Name: Anonymous 2013-03-15 22:05

>>53
YAINT NO MY FUCKIN NAME. WAT R U, A FUCKIN STACK BOY?

>>54
ROCK AWWWWWWN!

Name: 55 2013-03-15 22:07

O SHIT >>53 WAS ME

Name: Anonymous 2013-04-09 2:15

>>48
Hello mudda
Hello fadda

here I am @

camp grenada

den dey shuved a grenade in my anus

ouch!

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