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 2009-02-25 10:22

Sorry. I should've copied and pasted it.

srand ( time(NULL) );

ad = rand() % 6 + 1;

if ( ad == 1 )
word[20] = "Success";
if ( ad == 2 )
word[20] = "Failure";
if ( ad == 3 )

etc etc.

not sorted out all my possible values yet. before I go writing/copy pasting too much of that, I'd rather have it WORK.

Any idea why it won't work? It's saying "incompatible types in assignment"

Is there any more efficient way to do this?

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