View Single Post
Old 02-26-2006, 07:21 AM   #4 (permalink)
destin
Code Monkey
 
Join Date: Mar 2005
Location: NJ
Posts: 40
destin is on a distinguished road
Well, I'll just point out that there's an easier way of going about getting random consonants and random vowels:
Code:
char randomConsonant() {
    srand ((unsigned)time(0));
    char c;
    do {
        c = (rand() % ('a' - 'z' + 1)) + 'a';
    } while ((c == 'a') || (c == 'e') || (c == 'i') || (c == 'o') || (c == 'u'));
    
    return c;
}

char randomVowel() {
    srand ((unsigned)time(0));
    char c;
    do {
        c = (rand() % ('a' - 'z' + 1)) + 'a';
    } while ((c != 'a') && (c != 'e') && (c != 'i') && (c != 'o') && (c != 'u'));
    
    return c;
}

Last edited by destin; 02-26-2006 at 11:03 AM.
destin is offline   Reply With Quote