I need to input a phone number in the exact form (555) 555-5555 and using the strtok, extract the area code as a token which I have started like this
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void main()
{
char pNum[15];
char *tokenPtr;
printf("Enter a phone number is this format (555) 555-5555: ");
gets(pNum);
*tokenPtr = strtok(pNum, " ");
which extracts the area code, but this is where I get stuck. I need to convert the area code to an integer variable, then extract the first three digits, (save that string), and the last 4. Concatenate the 7 numbers, then convert to a long variable.
Print the labeled 3 digit area code as the integer(without any other characters). Then print the labeled 7 numbers as a long(without any other characters).
Can anyone help???
Code tags added by kermi3