how would this be done
int main(void)
{
char string[]="231 number 73 word 1 2";
char *ele;
ele=strtok(string," ");
while (ele != NULL)
{
if (*ele == '0' || *ele == '1' || *ele == '2' || *ele == '3' || *ele == '4' || *ele == '5' ||
*ele == '6' || *ele == '7' || *ele == '8' || *ele == '9')
TTS(ele);
else
printf("%s\n", ele);
ele=strtok(NULL," ");
}
return 0;
}
I'm trying to separate the words from the numbers. So when tokenizing it encounters a number I can pass it to an array.
the TTS function is what should be able to do it
]
void TTS(char *punt)
{
printf("%s\n",punt);
int i=0;
char num[20]; //where I wanna store the number
for (i=0;i<20;i++)
{
*punt=num[i];
punt++;
printf("%c",num[i]);
}
for (i=0;i<20;i++)
printf("%c",num[i]); //checking if anything is stored
}
Output is:
231
which corresponds to the first printf in TTS, which I added to make sure that at least it prints the number as a string.
I'm newb, have trouble with pointers and arrays. I'm sure there's an easy way around this. Any help?