splitFirst

Can anyone shed some light on how to do this? I need to do it for a class project and don't know where to start
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
  // testsplit.cpp
// test the splitFirst() function

#include <iostream>
#include <cstdlib>


using namespace std;

// split the string into the first space-delimited token and the rest
// return the token in t and the rest as the return value
string splitFirst(string s, string &t)
   {
      
   }  // splitFirst()

int main()
   {
      string s="There is no rest for the ones god blessed";   // Richard Thompson
      string t="";

      while (s.length() > 0)
         {
            s = splitFirst(s,t);
            cout<<"First: '"<<t<<"'   Remainder: '"<<s<<"'"<<endl;
         }
   }
Topic archived. No new replies allowed.