当前位置:编程学习 > C/C++ >>

C++之strtok实例代码详解

C 之strtok实例代码详解

#include <stdio.h>
#include <string>
#include <iostream>
#include <fstream>
#include <vector>
#include <string.h>
#include <stdlib.h>

using namespace std;

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

            if(c)
                cout<<"F:"<<c<<"  ";
            c = strtok(NULL, needle);
            if(c)
                cout<<"R:"<<c<<endl;
        }  
    }
    return 0;
}
补充:软件开发 , C++ ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,