Jump to content
Welcome, Guest
Existing user? Sign In

Sign In



Sign Up
The MatriX
  • Welcome To Ghbsys
  • CS GO Streaming Version is released. Have fun streaming while cheating!
  • Have a Payment Issue? Send us a Support ticket.
  • Make a thread if you need support or join our discord for live support.
  • Have Suggestions? Make a thread and you'll earn Ghbsys Points for implemented suggestions.
  • Join our discord to stay well connected! Don't forget to integrate your discord to the site
  • Welcome to [GHB] - GAmEhAcKbAsTaRdS Forum

    Welcome to [GHB] - GAmEhAcKbAsTaRdS Forum, like most online communities you must register to view or post in our community, but don't worry this is a simple free process that requires minimal information for you to signup. Be apart of [GHB] - GAmEhAcKbAsTaRdS Forum by signing in or creating an account.
    • Start new topics and reply to others
    • Subscribe to topics and forums to get email updates
    • Get your own profile page and make new friends
    • Send personal messages to other members.

    How do i split a String into a Array?!


    ~Beefy~
     Share

    Recommended Posts

    English:

     

    Hello everybody, i dont know how i "split" a string into array... like in visual basic!!... well.

    this is my function:

    void StringSplit(string str)
    {
    string
    istringstream iss(str);
    do
    {
    	string sub;
    	iss >> sub;
    	cout << "Substring: " << sub << endl;
    } while (iss);
    }

     

    Now i split a String, maybe "hello its me" and give it out in a array.

    but how do i save it in a array?

    is it so easy with:

    string array[];
    array[0] = "abc";
    array[1] = "def";
    array[2] = "ghi";

     

    ?!

    Please, i need your help!!

     

     

     

     

     

    German:

     

    Hallöschen, ich bräuchte mal hilfe, und zwar folgendes. ich möchte einen string, z.b. "der hans ist da" einen array "spliten", so

    wie in visual basic. also meine jetzige funktion "splitet" den array und gibt sie direkt aus, ohne sie in eine variable zu speichern.

    void StringSplit(string str)
    {
    string
    istringstream iss(str);
    do
    {
    	string sub;
    	iss >> sub;
    	cout << "Substring: " << sub << endl;
    } while (iss);
    }

     

    ich hab da so ne vermutung:

    string array[];
    array[0] = "abc";
    array[1] = "def";
    array[2] = "ghi";

     

    Sieht schonmal nich verkehrt aus oda?

    Nun, ich weiß dass der string immer nur in 3 teile gesplitet werden kann, da es sich da um userfiles handelt.

    d.h. eine .account datei sähe so aus:

    bernd

    topsecret

    100

    dann würde ich gerne so haben:

    array[0] = "bernd";
    array[1] = "topsecret";
    array[2] = "100";

    100 sind z.b. punkte

     

    Hat da jemand ne soloution pls? O.o

    HELFT MIR BIIITTE

    Link to comment
    Share on other sites

    So:

    void StringExplode(string str, string separator, vector<string>* results){ 
      int found; 
      found = str.find_first_of(separator); 
      while(found != string::npos){
      if(found > 0){ 
    	 results->push_back(str.substr(0,found)); 
      } 
      str = str.substr(found+1); 
      found = str.find_first_of(separator);
      } 
      if(str.length() > 0){
      results->push_back(str); 
      } 
    }

    Link to comment
    Share on other sites

    Guest
    This topic is now closed to further replies.
     Share

    • Recently Browsing   0 members

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