I have problem in reqruired output
the input is
333-0092-8868389
required output is
Country code is = 0092
City code is = 333
7-digit number is = 8868389
Phone number in correct sequence is = 0092-333-8868389
The full code is
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
void main()
{
char ch,*str,*country,*city,*digit;
cout<<"Enter the complete phone number: "<<endl;
gets(str);
char *first=strtok(str,"-");
char *second=strtok(NULL,"-");
char *third=strtok(NULL,"-");
if(strlen(first)==4 && strlen(second)==3)
{
strcat(country,first);
strcat(city,second);
strcat(digit,third);
}
else if(strlen(first)==3 && strlen(second)==4)
{
strcat(city,first);
strcat(country,second);
strcat(digit,third);
}
else if(strlen(first)==7 && strlen(second)==4)
{
strcat(digit,first);
strcat(country,second);
strcat(city,third);
}
else if(strlen(first)==7 && strlen(second)==3)
{
strcat(digit,first);
strcat(city,second);
strcat(country,third);
}
cout<<"Country code is :"<<country<<endl;
cout<<"City code is :"<<city<<endl;
cout<<"7-digit number is :"<<digit<<endl;
cout<<"Phone number in correct sequence is: "<<country<<"-"<<city<<"-"<<digit<<endl;
getch();
}