strtok标记多个值
来源:百度知道 编辑:UC知道 时间:2024/06/02 00:58:11
要用它把(123)456-1234分解成123 456 1234怎么弄啊??
//c++语言
#include<iostream>
#include<iomanip>
#include<cstring>
using namespace std;
int main()
{
const int arraysize=13;
char number[arraysize];
char *nptr;
cout<<"Enter the phone number:";
cin>>setw(13)>>number;//number=(123)456-1234
nptr=strtok(number+1,")");
cout<<nptr<<endl;
nptr=strtok(NULL,"-");
cout<<nptr<<endl;
nptr=strtok(NULL,"/0");
cout<<nptr<<endl;
return 0;
}
我也是刚做到这一题。