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:16

>>31
Use a better/smarter compiler moron.


[ Fri Dec 30 07:10:24 ]
[ @ ~/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){
            if(j != i-1 && j != len-i-2)
                putchar(space);
            else if(j == i-1)
                putchar(sl[i]);
            else if(j == len-i-2)
                putchar(sl[len-i-1]);
        }
        putchar(sl[len-1-i]);
        putchar(nl);
    }
    for(i=0;i<=len;++i)
        putchar(sl[len-i]);
    putchar(nl);
    for(i=0;i<len;++i){
        for(j=0;j<=i;++j)
            putchar(sl[j]);
        for(j=i+1;j<len;++j)
            putchar(sl[len-j]);
        putchar(nl);
    }
    puts(psl[0]);
    puts(psl[1]);
    puts(psl[2]);   
}
[ Fri Dec 30 07:10:50 ]
[ @ ~/host/prog/sl ] $ gcc -std=c89 -pedantic sl.c
sl.c:2: warning: return type of ‘main’ is not ‘int’
[ Fri Dec 30 07:10:53 ]
[ @ ~/host/prog/sl ] $ ./a.out
kodak is a fag
oo          aa
d d        f f
a  a         
k   k    a   a
             
i     is     s
s     is     i
             
a   k    a   k
   a         a
f d        f d
ao          ao
gaf a si kadok
kgaf a si kado
koaf a si kado
kodf a si kado
koda a si kado
kodaka si kado
kodak  si kado
kodak isi kado
kodak isi kado
kodak is  kado
kodak is akado
kodak is a ado
kodak is a fdo
kodak is a fao
kodak is a fag
Fuck Kodak
Fuck him in the anus
Fuck him good
[ @ ~/host/prog/sl ] $ rm a.out
[ Fri Dec 30 07:14:44 ]
[ @ ~/host/prog/sl ] $ tcc sl.c
[ Fri Dec 30 07:14:46 ]
[ @ ~/host/prog/sl ] $ ls
a.out  sl.c

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