newbie needs help with strtok function
Need to write a program that inputs a telephone number as a string in the form (608) 123-1234. This program should use strtok function to extract the area code as a token, the first three digits of the number as a token, and the last four digits of the number as a token as well. The seven digits of the phone number should be concatenated into one string. The program 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 out.
strtok and using int & long for phone number
This is what I have so far on this phone number program using the instructions above but it still isn't working correctly. HELP!
#include <string.h>
#include <iostream>
using std::cout;
using std::cin;
int main(int argc, char **argv)
{
char phone[]="(areacode) prefix-suffix";
char *areacode , *prefix , *suffix;
char *toks1 = " -";
char *toks = "()";
char *end = phone+strlen(phone);
areacode = strtok( phone, toks );
prefix = strtok( NULL, toks1 );
suffix = strtok( NULL, toks1 );
cout <<"Enter your phone number using this format (nnn) nnn- nnnn:";
cin >> areacode >> prefix >> suffix;
printf( "areacode=(%s) , prefix=%s, suffix=%s\n", areacode, prefix, suffix );
cout << "\nstrcat (areacode, prefix, suffix) = " << strcpy(end, phone) << strcat(prefix, suffix);
return 0;
}