my code is supposed to take a phone# as a string in (555) 555-5555 type of form using a strotk to take out the area code as a token, the 1st 3 digigts as another token, the last 4 as another token the 7 digits should be concatenated into 1 string it sould alos convert the area code string to an int and the phone # to a long and print the number
and it should be looped 3 times here is the code what is wrong with this stuoid thing:
#include "stdafx.h"
#include <cstring>
#include <iostream>
using namespace std;
int main()
{ char *phone[15];
char *area[7];
char *num[10];
int areaCode;
char* tokenPtr;
long int pnum;
for (int i=0; i<3; i++){
cout<<"Enter a phone number[(###) ###-####]: ";
cin.getline(phone,15);
strtok(num, "()");
areaCode=atoi(area);
strtok(NULL, "-");
strcpy(num,phone);
strtok(NULL, "");
strcat(phone,num0);
pnum=atol(phone);
cout<<area<<num;}
return 0;
}
![]()



LinkBack URL
About LinkBacks




