Skip to content

Commit 174313c

Browse files
author
Michael Mork
committedNov 23, 2017
--
0 parents  commit 174313c

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed
 

‎.DS_Store

6 KB
Binary file not shown.

‎a.out

8.54 KB
Binary file not shown.

‎exclude.c

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#include <stdio.h>
2+
#include <string.h>
3+
#include <stdio.h>
4+
#include <stdlib.h>
5+
6+
char *characterTable = NULL;
7+
8+
void sizeCharacterTableForasciiSymbol(unsigned ash) {
9+
int h = (int)ash;
10+
int thresh = sizeof(characterTable);
11+
if (h >= thresh) {
12+
characterTable = realloc(characterTable, sizeof(char) * h);
13+
}
14+
}
15+
16+
char * exclude(char *exclude, char *fromThese) {
17+
characterTable = malloc(sizeof(char *));
18+
19+
int indicesCount = 0;
20+
int i;
21+
for (i=0; exclude[i]!='\0'; i++) {
22+
char fromThis = exclude[i];
23+
if (fromThis == *" ") {
24+
continue;
25+
}
26+
unsigned asciiValue = (int)fromThis;
27+
sizeCharacterTableForasciiSymbol(asciiValue);
28+
characterTable[asciiValue] = fromThis;
29+
}
30+
31+
char *survived = malloc(i*(sizeof(char)) + 1);
32+
indicesCount = 0;
33+
i = 0;
34+
for (i=0; fromThese[i]!='\0'; i++) {
35+
char fromTheuse = fromThese[i];
36+
unsigned asciiValue = (int)fromTheuse;
37+
char compare = characterTable[asciiValue];
38+
if (fromTheuse != compare) {
39+
survived[indicesCount] = fromTheuse;
40+
indicesCount++;
41+
}
42+
}
43+
free(characterTable);
44+
return realloc(survived, indicesCount*sizeof(char));//survived;
45+
}
46+
47+
int main() {
48+
char *ex = "aBC d f F G nmlt q Q R o ST uvz";// = exa;
49+
char *fr = "abcdefgHIJKLMNOPQRSTUVwxyz";// = fro;
50+
char *e = exclude(ex, fr);
51+
printf("exclude: %s\n", ex);
52+
printf("from: %s\n", fr);
53+
printf("\n----\n");
54+
printf("result: %s\n", e);
55+
}
56+

0 commit comments

Comments
 (0)
Please sign in to comment.