Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h> // You'll need this later on for srand()
const char filename[]="syllables.txt"; //file to read from
const int num=105; //number of syllables
const char syllables[][]={ // You have to give sizes for all but the
// right-most brackets. It would be easier to replace that
// with const char *syllables[]={
"a", "ba", "be", "bi", "bo", "bu", "ca", "ce", "ci", "co", "cu", "da", "de",
"di", "do", "du", "e", "fa", "fe", "fi", "fo", "fu", "ga", "ge", "gi", "go",
"gu", "ha", "he", "hi", "ho", "hu", "i", "ja", "je", "ji", "jo", "ju" "ka",
"ke", "ki", "ko", "ku", "la", "le", "li", "lo", "lu", "ma", "me", "mi", "mo",
"mu", "na", "ne", "ni", "no", "nu", "o", "pa", "pe", "pi", "po", "pu", "qua",
"que", "quo", "qui", "ra", "re", "ri", "ro", "ru", "sa", "se", "si", "so",
"su", "ta", "te", "ti", "to", "tu", "u", "va", "ve", "vi", "vo", "vu", "wa",
"we", "wi", "wo", "wu", "ya", "ye", "yi", "yo", "yu", "za", "ze", "zi", "zo", "zu"};
int main(void)
{
char *name; // You're not reserving memory here, but later on you're
// trying to use it like it has memory available. Turn this into an array or
// malloc() some memory for it.
int namenum=random(2)+2; // This is not how you use random(). I'm
// guessing that you want a random number between 2 and 3. You
// can replace that line with this: int namenum=(rand()%2)+2; but only
// do this after srand() is called. Declare namenum here, but
// Don't assign it a value until further down.
// You should declare i outside the for loop just for portability's sake
int i;
srand(time(NULL)); // So you get different random numbers each time
for(i=0;i<namenum;i++)
{
name[i]=syllables[random(num)]; // As stated previously, name cannot
// be used this way until memory has been set aside for it. You also are using
// random() incorrectly. Replace it with rand()%num
}
printf("%s\n",name); // Don't forget the newline
// You also need to print name differently if you're planning
// on keeping the same type of for loop. Your for loop
// isn't creating a string. It's just an array of strings.
return 0;
}