Jump to content

Anyone have a StringSplit() function for C?


AzKay
 Share

Recommended Posts

in C++; I used;

vector <string> split(string line, string delims){
    string::size_type bi, ei;
    vector<string> words;

    bi = line.find_first_not_of(delims);
    while(bi != string::npos){
        ei = line.find_first_of(delims, bi);
        if(ei == string::npos)
            ei = line.length();
        words.push_back(line.substr(bi, ei-bi));
        bi = line.find_first_not_of(delims, ei);
    }
    return words;
}

Though, doesnt seem to be backwards compatible.

So, ive been googling but havnt came up with anything.

# MY LOVE FOR YOU... IS LIKE A TRUCK- #
Link to comment
Share on other sites

Have a look at strtok and wcstok

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...