65,211
社区成员
发帖
与我相关
我的任务
分享
int main()
{
char str[]="abc/def@111";
char s1[5],s2[5],s3[5];
sscanf(str,"%[^/]/%[^@]@%s",s1,s2,s3);
cout<<s1<<endl;
cout<<s2<<endl;
cout<<s3<<endl;
}
#include<string>
#include <iostream>
using namespace std;
int main()
{
char a[]="abc/def@111";
char b[3][6]={0};
int m=0;
int i=0;
int j=0;
while(a[m]!='\0')
{
if(a[m]!='/'&&a[m]!='@')
{
b[i][j]=a[m];
m++;
j++;
}
else
{
i++;
m++;
j=0;
}
}
for(i=0;i<3;i++)
for(j=0;j<6;j++)
{
cout<<b[i][j];
}
return 0;
}
char str[]="abc/def@111";
char *a, *b, *c;
a = str;
b = strtok(a, '\/');
c = strtok(b, '\@');
char str[]="abc/def@111";
char *a, *b, *c;
a = str;
b = strok(a, '\/');
*b = 0;
++b;
c = strok(b, '\@');
*c = 0;
++c;
// a, b, c