Solution 01View more random threads:
- MGT619 Final Project Management Assignment 01...
- HRM624 Conflict Management Assignment No. 01 Fall 2014...
- Required solution or helping material ENG101 assignment 01...
- MGT402 Cost & Management Accounting Assignment No. 01...
- Assignment No. 01 Human Resource Management (MGT501) Fall...
- CS403 - Database Management Systems Assignment 6 Deadline...
- ENG201 - Business and Technical English Writing spring 2011...
- MGMT623 Leadership & Team Management Assignment No.2 Fall...
- CS304 Object Oriented Programming Assignment 02 Fall 2014...
- FIN624 Islamic Modes OF Financing Assignments No 2 Ideal...
Solution 2Code:#include <iostream> #include <cstring> using namespace std; main(){ char Directory[16],part1[3],part2[4], part3[7]; char *Tptr; int size; cout<<"Enter the complete phone number (as \"0092-123-1234567\") :"; cin>>Directory; Tptr=strtok(Directory, "-"); while(Tptr!=NULL ){ cout<<Tptr<<"\n"; size=strlen(Tptr); switch(size){ case 4: strcpy(part2, Tptr); break; case 3: strcpy(part1, Tptr); break; case 7: strcpy(part3, Tptr); break; } Tptr=strtok(NULL,"-"); } cout<<endl<<"Country Code is ="<<part2<<"\nCity code is ="<<part1<<"\n7-digit number is = "<<part3<<"\nPhone number in correct sequence is ="<<part2<<"-"<<part1<<"-"<<part3; system("Pause");}
Code:#include <iostream> #include <cstring> #include <string.h> #include <conio.h> using namespace std; main(){ char Directory[16],part1[3],part2[4], part3[7], *Tptr; int size; cout<<"Enter the complete phone number :"; cin>>Directory; Tptr=strtok(Directory, "-"); do{ size=strlen(Tptr); switch(size){ case 4: strcpy(part2, Tptr); break; case 3: strcpy(part1, Tptr); break; case 7: strcpy(part3, Tptr); break; } Tptr=strtok(NULL,"-"); }while(Tptr!=NULL ); cout<<endl<<"Country Code is ="<<part2<<"\nCity code is ="<<part1<<"\n7-digit number is = "<<part3<<"\nPhone number in correct sequence is ="<<part2<<"-"<<part1<<"-"<<part3; getch();}
Sponsored Links
:o:o--------------------------------------------------------------------------------------:o:o
[B]The more knowledge you have, the greater will be your fear of Allah.[/B]
Please Join My [B]Group Vuhelp[/B][B], Birthday Wishing, Daily Hadees[/B] [CODE][B]http://vuhelp.net/groups/vuhelp.html[/B]
[B]http://vuhelp.net/groups/birthday-wishing.html[/B]
[B]http://vuhelp.net/groups/daily-hadees.html[/B][/CODE]
[CENTER][B][COLOR="Red"][SIZE="4"]Email: [email]viki@vuhelp.net[/email][/SIZE][/COLOR][/B][/CENTER]
There are currently 1 users browsing this thread. (0 members and 1 guests)