>>sent[num];
what you should do here us use strcpy() to copy the first random string into sent variable, then strcat() to copy each of the other strings.
>>printf("\n\n%s %s %s %s %s %s.\n\n", a[i], n[i], v[i], p[i], a2[i], n2[i]);
variable i is not a random number. you should use variable num instead of i.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
To AncientDragon : the a[num],v[num]... doesn't work,because num is the same in that insant moment(i tried that).
To Little E :1.Offtopic: next time try to type the code between code.../code tags ;)
2.What you need is this :
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
const char *a[5] = {"The", "A", "One", "Some", "Any"};
const char *n[5] = {"boy", "girl", "dog", "town", "car"};
const char *v[5] = {"drove", "jumped", "ran", "walked", "skipped"};
const char *p[5] = {"to", "from", "over", "under", "on"};
const char *a2[5] = {"the", "a", "one", "some", "any"};
const char *n2[5] = {"boy", "girl", "dog", "town", "car"};
int i = 0;
srand((unsigned)time(NULL));
for( i = 0; i <= 4; i++)
{
printf("\n\n%s %s %s %s %s %s.\n\n", a[rand()%5], n[rand()%5], v[rand()%5], p[rand()%5], a2[rand()%5], n2[rand()%5]);
}
return 0;
}
Now,i've deleted the sent string,and the num variable,because u don't need them.
I hope the code above answers your problem
Good luck
Eko
Junior Poster in Training
60 posts since Nov 2006
Reputation Points: 12
Solved Threads: 1
To AncientDragon : the a[num],v[num]... doesn't work,because num is the same in that insant moment(i tried that).
You are right -- my suggestion was not what he wanted. :)
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343