So I'm using Mysql to make a text-to-speech engine. Basically any given phrase by the database is returned to my script, which has to say every word and number, if any, by way of voice . For the voices I'm using Asterisk, but that's another problem of my own lol
The problem I'm having is this: the sql results are given in way of arrays, like this:
char test[10][20]
so test[0] is the first line of query, test[1] second and so on.
So I just use the strtok function on the array using " " (space) as the tokenizer and get the words. But strtok uses pointers as the words it stores, right?
How would I go about converting the word the pointer stores into an array? This would be helpful specially if there are any numbers, since I've already programed a function that reads an array of numbers and says it to Asterisk.
while ((row = mysql_fetch_row(res)) != NULL)
{
/*Copy the array to an auxiliary array for processing*/
strcpy(test[0],row[0]);
int i;
char num;
/* Convert all letters to lowecase */
for (i=0 ;test[0][i]; i++)
test[0][i]= tolower(test[0][i]);
/* Separate the phrase into words */
char token[] = " ";
char *word = NULL;
word = strtok(test[0], token);
/* If word is a number */
while (word != NULL)
{
if (*word == '0' || *word == '1' || *word == '2' || *word == '3' || *word== '4' || *word == '5' ||
*word == '6' || *word == '7' || *word == '8' || *word == '9')
{
*word=num; //Here is where I'm just messing around trying to get the contents of word into an array, since my TTS function reads character by character
TTS(num);
}
else
StreamFile(word); //If word is not number, then say it
word = strtok(NULL,token);
}
}
So how would I go about getting the content of word into an array of any kind so I can access individual characters?
I'm kinda noob also so be gentle