Skip to content

Instantly share code, notes, and snippets.

@jmjuanes
Last active October 4, 2015 11:57
Show Gist options
  • Select an option

  • Save jmjuanes/08b693b1f2673c70e8db to your computer and use it in GitHub Desktop.

Select an option

Save jmjuanes/08b693b1f2673c70e8db to your computer and use it in GitHub Desktop.

Revisions

  1. jmjuanes revised this gist Oct 4, 2015. No changes.
  2. jmjuanes renamed this gist Oct 3, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions string2array.cpp → TabStringToArray.cpp
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    //Number of elements of the array
    const int N = 11;

    //Function String to array
    void StringToArray(string str, string arr[])
    //Function Tabulated String to array
    void TabStringToArray(string str, string arr[])
    {
    //Aux vars
    int pos = 0;
  3. jmjuanes created this gist Oct 3, 2015.
    22 changes: 22 additions & 0 deletions string2array.cpp
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    //Number of elements of the array
    const int N = 11;

    //Function String to array
    void StringToArray(string str, string arr[])
    {
    //Aux vars
    int pos = 0;

    //Read all
    for(int i = 0; i < N; i++)
    {
    //Find the next tab
    pos = str.find("\t");

    //Get the substring
    arr[i] = str.substr(0, pos);

    //Cut the string
    str = str.substr(pos + 1);
    }
    }