In: Computer Science
Write a function called tokenizeTelNum that inputs a telephone number as a string in the form (555) 555-5555. The function should use the function strok to extract the area code as a token, the first three digits of the phone number as a token and the last four digits of the phone number as a token. The seven digits of the phone number should be concatenated into one string. The function should convert the area code string to int and convert the phone number string to long. Both the area code and the phone number should be printed. This should be written in C and written as a FUNCTION named tokenizeTelNum that can be called later in main. You must input the telephone number from the user and use strok thank u
#include<stdio.h>
#include <string.h>
void tokenizeTelNum (char *c){
char *p;
char arr[3];
p = strtok (c,"-");
// converting token string to int
int num = (p[1]-48);
num = num * 10 + (p[2]-48);
num = num * 10 + (p[3]-48);
p = strtok (c,"-");
p = strtok (c,"-");
// converting phone string to int
long phone = (p[10]-48);
phone = phone * 10 + (p[11]-48);
phone = phone * 10 + (p[12]-48);
phone = phone * 10 + (p[13]-48);
printf("Toaken : %d\n",num);
printf("Phone : %ld\n",phone);
}
int main(){
int arr[100];
printf("Enter number");
scanf("%s",arr);
tokenizeTelNum(arr);
return 0;
}