What can I do to make this better?
I have to take a phone number in the form of (111) 111-1111 and display only the numbers. I must use the strtok function. This is the function I wrote to do this but am looking for something that is better and for someone to explain if I used a poor practice. My driver just sends an array that I assign the number above.
Code:
char *separate(char *string1)
{
char *token;
token = strtok(string1, "() -");
string1 = token;
while ((token = strtok(NULL, "() -")) != NULL)
{
*strcat(string1, token);
}
return string1;
}
Thanks