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

Shit in C

Name: Anonymous 2009-02-25 10:09

I'm trying to set the contents of a string based on what random number is generated by my srand.

dice = rand() % 10 + 1;

if ( dice = 1 )
word[20] = "Success";

^-- this shit doesn't work, though.

tl;dr. I want my "dice rolls" to generate a random number, random number corresponds to a pre-set word, and the preset word to be printed.

I'm probably going about it the wrong way. Suggestions from experts?

Name: Anonymous 2011-12-30 19:02


[ Fri Dec 30 07:01:20 ]
[ @ ~/host/prog/sl ] $ cat sl.c
#include <stdio.h>
void main()
{
    const char space = ' ';
    const char nl = '\n';
    const char *psl[] = {
        "Fuck Kodak",
        "Fuck him in the anus",
        "Fuck him good"
    };
    char sl[] = "bodak is a fag";
    int i,j,len;
    sl[0] = 'k';
    len=sizeof(sl)/sizeof(char)-1;
    puts(sl);
    for(i=1;i<len-1;++i){
        putchar(sl[i]);
        for(j=0;j<len-2;++j)
            putchar(space);
        putchar(sl[len-1-i]);
        putchar(nl);
    }
    for(i=0;i<=len;++i)
        putchar(sl[len-i]);
    putchar(nl);
    puts(psl[0]);
    puts(psl[1]);
    puts(psl[2]);   
}
[ Fri Dec 30 07:01:25 ]
[ @ ~/host/prog/sl ] $ ./a.out
kodak is a fag
o            a
d            f
a            
k            a
             
i            s
s            i
             
a            k
             a
f            d
a            o
gaf a si kadok
Fuck Kodak
Fuck him in the anus
Fuck him good

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