Add creation of word list

This commit is contained in:
XOR 2022-10-30 21:03:06 +01:00
parent 55a65ebec9
commit 45af1fd41f
10 changed files with 3791 additions and 0 deletions

4
.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
.vscode/
.fleet/
*.out
debug.txt

File diff suppressed because it is too large Load diff

71
Aufgabe 1/main.c Normal file
View file

@ -0,0 +1,71 @@
#include <stdio.h>
//#include <stdlib.h>
#define SIZEOFARR(a) (sizeof(a)/sizeof(a[0]))
char allowedChars[] = "aäbcdefghijklmnoöpqrstuüvwxyzAÄBCDEFGHIJKLMNOÖPQRSTUÜVWXYZß \n";
unsigned short int arrContains(char checkForVal, char *checkInArr, int arrSize)
{
for (int i = 0;i<arrSize;i++)
{
if(checkForVal==checkInArr[i]){
return 1;
}
}
return 0;
}
int main(int argc, char const *argv[])
{
char words[30000][20];
FILE *fp;
FILE *fpp;
fpp = fopen("/home/xor/coding/BwInf_41_1/Aufgabe 1/debug.txt","w");
fp = fopen("/home/xor/coding/BwInf_41_1/Aufgabe 1/Alice_im_Wunderland.txt", "r");
//fp = fopen("/home/xor/Dokumente/Coding/BwInf_41_1/Aufgabe 1/test.txt", "r");
if(fp == NULL||fpp==NULL)
{
printf("Datei konnte nicht geoeffnet werden.\n");
return -1;
}
int word = 0;
int character = 0;
int word_found = 0; //checks if multiple spaces are behind each other, we don't want to add a new word
while(1){
char curr_char = fgetc(fp);
if(curr_char==EOF)
{
break;
}
if (!arrContains(curr_char,allowedChars,SIZEOFARR(allowedChars)))
{
continue;
}
else if (curr_char==' '|| curr_char=='\n')
{
if (word_found)
{
word++;
character = 0;
word_found = 0;
}
}
else{
word_found = 1;
words[word][character]=curr_char;
character++;
}
}
for(int i=0; i<=word;i++){
fprintf(fpp,"%s ", words[i]);
printf("%s ",words[i]);
}
return 0;
}

1
Aufgabe 1/stoerung0.txt Normal file
View file

@ -0,0 +1 @@
das _ mir _ _ _ vor

1
Aufgabe 1/stoerung1.txt Normal file
View file

@ -0,0 +1 @@
ich muß _ clara _

1
Aufgabe 1/stoerung2.txt Normal file
View file

@ -0,0 +1 @@
fressen _ gern _

1
Aufgabe 1/stoerung3.txt Normal file
View file

@ -0,0 +1 @@
das _ fing _

1
Aufgabe 1/stoerung4.txt Normal file
View file

@ -0,0 +1 @@
ein _ _ tag

1
Aufgabe 1/stoerung5.txt Normal file
View file

@ -0,0 +1 @@
wollen _ so _ sein

25
Makefile Normal file
View file

@ -0,0 +1,25 @@
all:
@make aufgabe1
aufgabe1:
@echo 'Compiling Aufgabe 1'
@echo ''
@gcc Aufgabe\ 1/main.c -o aufgabe1.out
@echo ''
runall:
@make aufgabe1
@make runA1
runA1:
@make aufgabe1
@echo 'Running Aufgabe 1:'
@echo ''
@./aufgabe1.out
@echo ''
@make clean
clean:
@echo 'Cleaning up'
@rm *.out