Created
October 2, 2017 18:42
-
-
Save macroxela/5bcce2fc0af09d0dd3ffbf987d0e25b6 to your computer and use it in GitHub Desktop.
A C++ string parser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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