Created
December 8, 2015 12:36
-
-
Save leolabs/50814680019961cdbdd9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// | |
// Created by Leo Bernard on 07/12/15. | |
// | |
#include "functions.h" | |
#include <iostream> | |
using namespace std; | |
string trimme(string s) { | |
string out1 = ""; | |
for(int i = 0; i < s.length(); i++) { | |
if(s.at(i) != ' ' && s.at(i) != '\r') { | |
for(int j = i; j < s.length(); j++) out1 += s.at(j); | |
break; | |
} | |
} | |
string out2 = ""; | |
for(int i = out1.length() - 1; i >= 0; i--) { | |
if(out1.at(i) != ' ' && s.at(i) != '\r') { | |
for(int j = 0; j <= i; j++) out2 += out1.at(j); | |
break; | |
} | |
} | |
return out2; | |
} | |
void spalte_ab_erstem (string zeile, char split_char, string &s1, string &s2) { | |
bool foundChar = false; | |
for(int i = 0; i < zeile.length(); i++) { | |
if(zeile.at(i) == split_char && !foundChar) { | |
foundChar = true; | |
continue; | |
} | |
if(foundChar) { | |
s2 += zeile.at(i); | |
} else { | |
s1 += zeile.at(i); | |
} | |
} | |
} | |
string ersetze(string zeile, char zu_ersetzendes_zeichen, string ersatztext) { | |
string resultat = ""; | |
for(int i = 0; i < zeile.length(); i++) { | |
if(zeile.at(i) == zu_ersetzendes_zeichen) { | |
resultat += ersatztext; | |
} else { | |
resultat += zeile.at(i); | |
} | |
} | |
return resultat; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment