64,685
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main(void)
{
string str("asdf|dasf|asdf"),substr;
stringstream buf(str);
while(buf.good())
{
getline(buf,substr,'|');
cout<<substr<<endl;
}
system("pause");
return 0;
}
#include <stdio.h>
#include <string.h>
int main ()
{
char str[] ="asdf|dasf|asdf";
char * pch;
pch = strtok (str,"|");
while (pch != NULL)
{
printf ("%s\n",pch);
pch = strtok (NULL, ",");
}
return 0;
}