I want to make random word, but got stuck

so here's the code
1
2
3
4
5
6
7
8
9
randomize();
for(i=0;i<100;i++)
{
for(k=0;k<4;k++)
{
j = random(26)+65;
name[i][k] = (char) j;
}
}

so I want to make 100 random words with 4 length.
Random the ascii first in int then put it in with char.
Ive got alt+f9 successfully. But got an error when ctrl+f9. Is there anything wrong ?

==solved==
1
2
3
4
5
6
7
8
9
10
randomize();
for(i=0;i<100;i++)
{
for(k=0;k<4;k++)
{
j = random(26)+65;
name[i][k] = (char) j;
name[i][4] = NULL;
}
}

Last edited on
I'm assuming alt-f9 means compile and ctrl-f9 means run. Anyway, in your first for loop, you have the number 1 where you want the letter i.

I should also mention that if you want to use those "words" as c-strings, you'll want to make them one char longer and put a 0 there to null-terminate the string.
Last edited on
thanks for posting.
yeah alt_f9 compile and ctrl+f9 is run. At the first loop I mistype the variable with number. Sorry, I already corrected it.

To make the char longer is it by
char name[100][5]; ?
if so how to put 0 to null-terminate the string ?
Wohooo I already made it, thanks for the comment...
It's solved !!!
Topic archived. No new replies allowed.