#include "stringUtil.h" using namespace std; //MSVC++ contains a know bug in the getline function for strings. This function //acts as a fix to allow you to read input string from the user. When getline //is called one line, ending w/ the newline character, will be taken from the //specified stream and placed in the s string output parameter. //INPUT : is - A stream denoting where input is arriving from, e.g. cin, a file, etc. //INPUT : d - this character denotes the char value on which we end our getline. // e.g if you enter '.' for this variable, the string will stop when // the first '.' is encountered. This value is '\n' by default, so // if you want to simply break on the new line, YOU DON'T have to enter // anything for this parameter. //OUTPUT s - contains the string entered by the user. // // //EXAMPLE : //string sentence; //getline(cin,sentence); // void getline( istream& is, string& s, char d) { fflush(stdin); char getbuff[512]; is.getline(getbuff,512, d); s = getbuff; } //So that char * can be avioded in this homework, we have provided you with a //wrapper function for strok, which you used in the last homework. This function //behaves exactly as strtok except for 2 small changes. 1) the returned token //is a string and NOT a char *. 2) instead of passing NULL to the function to //continue parsing a string, pass "", the empty string. Similiarly, when there //are no tokens left in the string to return, newStrtok will return "", instead //of NULL. //INPUT: currString - represents the string to be parsed. After the initial call // to the fucntion, this value should be "". // seps - this string represnts the values on which to break tokens. Its usage // is exactly the same as strtok, except that the value is a string, not a char * // //OUTPUT: returns the next token in the string, seperated by the chars in the seps string. string newStrtok(string currString, string seps ) { static char tempStr[512]; char *tempToken; string returnStr; int val = currString.size(); if(currString.size()==0) tempToken = strtok(NULL,seps.c_str() ); else { for(int x=0;x