Initial commit

This commit is contained in:
theoleuthardt 2024-01-27 02:07:15 +01:00
commit 826d4c8c9d
81 changed files with 7268 additions and 0 deletions

30
uebung8/aufgabe4.c Normal file
View file

@ -0,0 +1,30 @@
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
int wordCount(const char *string){
int count = 0;
bool inWord = false;
size_t strSize = strlen(string);
printf("Länge des Strings: ");
printf("%zu\n", strSize);
for (; *string != '\0'; string++) {
if(*string == ' ' || *string == ',' || *string == '.'){
inWord = false;
} else {
if(!inWord){
count++;
inWord = true;
}
}
}
return count;
}
int main() {
char *string = "Coders are also just human with addictions and needs.";
printf("String: %s\n", string);
printf("Anzahl der Wörter im String: %d", wordCount(string));
return 0;
}