I'm trying to play around with a few functions to get the hang of them.
Basically, here I want to create a function that reads a phone number in the form of 111-222-3333 and tokenize the string with "-" as the delineater then use strcat to concatenate the string into a full phone number and print it.
This is what I've done so far, but it doesn't seem to be working. Any suggestions.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
char stringA[80];
char finishedNum[11];
cout << "enter a phone number in the form 555-555-5555" << endl;
cin.getline(stringA, 80);
char * tPntr = strtok(stringA, "-");
while (tPntr != NULL)
{
cout << tPntr << endl;
tPntr = strtok(NULL, "-");
strcat(finishedNum, tPntr);
}
cout << finishedNum;