C++之strtok实例代码详解

2014-11-24 13:09:00 · 作者: · 浏览: 4
C 之strtok实例代码详解

#include
#include
#include
#include
#include
#include
#include

using namespace std;

int main()
{
ifstream f("x.cfg");
string str;
while(getline(f,str))
{
if(str[0]==[)
cout< else
{
const char* needle="=";
char* ccc=const_cast(str.c_str());

char* c=strtok(ccc, needle);

if(c)
cout<<"F:"< c = strtok(NULL, needle);
if(c)
cout<<"R:"< }
}
return 0;
}