Skip to content

Instantly share code, notes, and snippets.

@macroxela
Created October 2, 2017 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save macroxela/5bcce2fc0af09d0dd3ffbf987d0e25b6 to your computer and use it in GitHub Desktop.
Save macroxela/5bcce2fc0af09d0dd3ffbf987d0e25b6 to your computer and use it in GitHub Desktop.
A C++ string parser
#ifndef _PARSER_H
#define _PARSER_H
#include <string>
using namespace std;
void cutstring(string &input, int pos)
{
string dummy = "";
for(int i = pos; i < input.length(); i++)
{
dummy += input[i];
}
input = dummy;
}
string concatenate(string &input)
{
string ls = "";
if(input == "")
{
return "";
}
int size = input.length();
int cnt = 0;
int i = 0;
while(isspace(input[cnt]))
{
cnt ++;
if(cnt == size)
return "";
}
if(cnt == size)
{
return "";
}
while(cnt < size)
{
if(isspace(input[cnt]))
break;
ls += input[cnt];
cnt++;
}
cutstring(input,cnt);
return ls;
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment