-
-
Save fwg/1334909 to your computer and use it in GitHub Desktop.
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
/* | |
* Stringverarbeitung.c | |
*/ | |
#include <stdio.h> // for printf, fgets, stdin | |
int main() { | |
printf("String insert:"); | |
char string[100]; | |
fgets(&(string[0]), 100, stdin); | |
char result[100]; | |
int pos = 0; | |
int i = 0; | |
char cond = 0; // in c there is no boolean and no false | |
for(i; i<100; i++){ | |
if(cond == 0){ // there is no false | |
if(string[i] == '/'){ | |
cond = 1; // there is no true | |
} | |
result[pos] = string[i]; | |
pos++; | |
}else{ | |
if(string[i] == '/'){ | |
continue; | |
}else{ | |
cond = 0; | |
result[pos] = string[i]; | |
pos++; | |
} | |
} | |
} | |
printf("%s", &(result[0])); // printf needs a format string | |
} |
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
/* | |
* Stringverarbeitung.cpp | |
* | |
* Created on: 02.11.2011 | |
* Author: Administrator | |
*/ | |
#include "Stringverarbeitung.h" | |
Stringverarbeitung::Stringverarbeitung() { | |
printf("String insert:"); | |
fgets(string, 100, scanf()); | |
char result[100]; | |
int pos = 0; | |
int i = 0; | |
boolean cond = false; | |
for(i; i<100; i++){ | |
if(cond == false){ | |
if(string[i] == "/"){ | |
cond = true; | |
} | |
result[pos] = string[i]; | |
pos++; | |
}else{ | |
if(string[i] == "/"){ | |
continue; | |
}else{ | |
cond = false; | |
result[pos] = string[i]; | |
pos++; | |
} | |
} | |
} | |
printf(result); | |
} | |
Stringverarbeitung::~Stringverarbeitung() { | |
// TODO Auto-generated destructor stub | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment