#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define SIZE 100

int main(void)
{
    char phoneNumber[SIZE];

    char areaCode[10] = "";
    char firstPart[10] = "";
    char lastPart[10] = "";

    char completeNumber[20] = "";

    printf("Enter a telephone number in the form ");
    printf("(555) 555-5555:\n");

    fgets(phoneNumber, SIZE, stdin);

    char *tokenPtr = strtok(phoneNumber, " ()-\n");

    if (tokenPtr != NULL)
    {
        strcpy(areaCode, tokenPtr);
    }

    tokenPtr = strtok(NULL, " ()-\n");

    if (tokenPtr != NULL)
    {
        strcpy(firstPart, tokenPtr);
    }

    tokenPtr = strtok(NULL, " ()-\n");

    if (tokenPtr != NULL)
    {
        strcpy(lastPart, tokenPtr);
    }

    strcat(completeNumber, firstPart);
    strcat(completeNumber, lastPart);

    int areaCodeValue = atoi(areaCode);
    long phoneNumberValue = atol(completeNumber);

    printf("\nArea code = %d\n", areaCodeValue);
    printf("Phone number = %ld\n", phoneNumberValue);

    return 0;
}