summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Chausse <benjamin@chausse.xyz>2022-09-29 18:41:55 -0400
committerBenjamin Chausse <benjamin@chausse.xyz>2022-09-29 18:41:55 -0400
commit682d62632e727c2746f6443e69dca219ec24984c (patch)
tree98c0b75efee6ca57e229f5e7022da8fb04d95482
parent41ba34778dac50813a72b5cf7f21eaeebc5c8c47 (diff)
Fix testData.h stringslibrary
-rw-r--r--format.h15
-rw-r--r--testData.h4
2 files changed, 5 insertions, 14 deletions
diff --git a/format.h b/format.h
index 519876c..2936e85 100644
--- a/format.h
+++ b/format.h
@@ -31,17 +31,8 @@ double pow(double b, int e){
}
}
-double avg(double arr[]){
- int len = COUNT_OF(arr);
- double sum = 0;
- for (int i=0;i<len;i++){
- sum += arr[i];
- }
- return sum/len;
-}
-
// Convert every character to lowercase
-char * lower(char *str){
+const char* lower(char *str){
int len = COUNT_OF(str);
for (int i=0; i<len; i++){
// Change all letters to lowercase
@@ -55,7 +46,7 @@ char * lower(char *str){
}
// Count the total number of spaces to define the new str size
-char * trim(char *str){
+const char* trim(char *str){
int spc =0;
for (int i=0; i<COUNT_OF(str); i++){
if (str[i] == ' '){
@@ -63,7 +54,7 @@ char * trim(char *str){
}
}
// Actually format the new string
- char nstr[COUNT_OF(str)-spc+1];
+ char *nstr = "";
int j = 0; // index inside the new str (nstr)
for (int i=0; i<COUNT_OF(str); i++){
if (str[i] != ' '){
diff --git a/testData.h b/testData.h
index ba7667f..00e6d33 100644
--- a/testData.h
+++ b/testData.h
@@ -17,7 +17,7 @@
// - Trailing spaces -> sis, heightened, minim
// - Spaces before the words -> sis, unholly, pop
// - Non latin alphabet (greek & russian)
-const char *wrd[] = {
+const char* wrd[] = {
"abba", "betrothed", "deified", "elevation", "genesis", "kayak", "murdum",
" pop", "relinquish", "stats", "thirst", "abhorrent", "accentuated",
"agoraphobia", " aibohphobia", "anemia", "bIb", "bittersweet", "bob",
@@ -28,7 +28,7 @@ const char *wrd[] = {
"peep", "penitentiary", " polymorphism", "poRtmanteau", "quizzaciously",
"racecar", "radar", "redder", "repaper", "rotator", "rotavator", "sagas",
" sis ", "solos", "superlative", "tartigrade", "tattarrattat", "tenacity",
- "tenet", " unholly", "wow" "élévation", "μουσικότητα", "неандерталец",
+ "tenet", " unholly", "wow", "élévation"
};
// }}}
// Sample numbers {{{