GROUPING OF NAMES :(

guys pls help me how to random this program that will result in grouping of names into three groups. pls help me guys.. the problem of my program is only one name will be output of the program... pls help me how to random all names and to group them..tnx.. heres the code..

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>

#define SYLNUM 104
#define MAXSYLLABLES 2

const char *syllables[SYLNUM] = {
"edrianne", "virmun", "francis", "penny", "mia", "cheska", "pj", "celine", "diane", "coddie", "kulot", "daniel", "dennis",
"daryl", "kim", "christie", "motero", "eddy", "gordo", "feng", "paul", "carcel", "prince", "jehlai", "wang", "kazuya",
"bob", "miguel", "karen", "sheryl", "chito", "lily", "cindy", "janet", "julia", "jiji", "joji", "jun", "ken",
"yushimitsu", "heiachi", "kazuya", "asuka", "long", "lei", "king", "jimpachi", "luis", "ben", "mart", "misa", "light",
"hideki", "lawliet", "nate", "river", "jen", "jenifer", "joseph", "pest", "alphie", "RS", "a", "e", "i",
"o", "u", "ba", "be", "bi", "bo", "bu", "ms", "me", "mi", "mo", "mu",
"sa", "se", "si", "so", "su", "ga", "ge", "valerie", "KC", "sharon", "piolo", "johnloid", "sam",
"milby", "jacob", "bela", "tonton", "yanyan", "chris", "yes", "no", "wala", "nko", "ma", "isip", "ha", "hai" };

int main(void)
{
char name[(MAXSYLLABLES * 1) + 1] = "";
int i;
int randSyl;

srand( time(NULL) );

for( i=0 ; i < rand() % (MAXSYLLABLES - 1) + 1 ; i++ )
{
randSyl = rand() % ( SYLNUM - 1 );
strncat ( name, syllables[randSyl], strlen(syllables[randSyl]) );
}
printf( "%s\n", name );
system("PAUSE");
return 0;
}
you know, those aren't syllables..
anyway, firstly make name is too short. it's only 3 chars long now.
then, repeat this MAXSYLABLES times:
get a random number (why do you subtract 1 from SYLNUM ?),
add it to name (there's no need for strncat. strcat would work fine)
sir tnx for responsed..
sir can you pls elaborate your instraction pls..
because i am a beginer.. pls can you give me a sample.. pls sir.. tnx
I would suggest you use string to handle this problem
This make things much more easy
ahh tnx sir..
Topic archived. No new replies allowed.