This repository has been archived by the owner on Mar 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.c
109 lines (74 loc) · 2.85 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include <stdio.h>
#include <stdlib.h>
#include "propaganda.h"
int main()
{
char* msg = newstr("Hello World!");
char* cpy = strcpy(msg);
cpy[0] = 'A';
printf("-> Length:\t%d\n", strlen(msg));
printf("-> Equals:\t%d\n", strequals(msg, "Hello World!"));
printf("-> Equals:\t%d\n", strequals(msg, "Hello!"));
printf("-> Concat:\t%s\n", strcat(msg, " This is Matthias speaking ... "));
printf("\n");
printf("-> IndexOf:\t%d\n", indexOf(msg, 'o'));
printf("-> LastIndexOf:\t%d\n", lastIndexOf(msg, 'o'));
printf("-> IndexOf:\t%d\n", indexOfString(msg, "World!"));
printf("-> LastIndexOf:\t%d\n", lastIndexOfString(msg, "World!"));
printf("\n");
printf("-> Substring:\t\"%s\"\n", substring(msg, 0, 6));
printf("-> Substring:\t\"%s\"\n", substr(msg, strlen("Hello ")));
printf("\n");
msg = newstr("Repeat, repeat, asdf, repeat, repeat repeat something ... ");
printf("-> Occurrence:\t%d\n", charOccurrence(msg, 'o'));
printf("-> SOccurrence:\t%d\n", stringOccurrence(msg, newstr("repeat")));
printf("-> Lowercase:\t%s\n", lowerCase(msg));
printf("-> Uppercase:\t%s\n", upperCase(msg));
printf("\n");
printf("-> Normal:\t%s\n", msg);
toLowerCase(msg);
printf("-> Lowercase:\t%s\n", msg);
toUpperCase(msg);
printf("-> Uppercase:\t%s\n", msg);
printf("\n");
msg = newstr("This is some random test!");
printf("-> Split(' '):\n\n");
char** parts = split(msg, ' ');
for (int i = 0; i < charOccurrence(msg, ' ')+1; i++)
printf("\t[%d]: \"%s\"\n", i, parts[i]);
printf("\n");
msg = newstr("This\r\nis\r\nsome\r\nrandom\r\ntext!\r\n ");
printf("-> Split(\\r\\n):\n\n");
parts = splits(msg, "\r\n");
for (int i = 0; i < stringOccurrence(msg, "\r\n")+1; i++)
printf("\t[%d]: \"%s\"\n", i, parts[i]);
printf("\n");
msg = newstr("Hello World!");
replace(msg, 'o', '0');
replace(msg, 'e', '3');
printf("-> Replace:\t%s\n", msg);
msg = newstr("Hello World!");
msg = replaceString(msg, "Hello", "H3ll0");
msg = replaceString(msg, "World", "h4x0rs");
printf("-> Replace:\t%s\n", msg);
printf("\n");
msg = newstr(" \n\rHello World!\n ");
printf("->Message:\t\"%s\"\n", msg);
printf("->Trimmed:\t\"%s\"\n", trim(msg));
printf("\n");
printf("->itos:\t%s\n", itos(1024));
printf("->btos:\t%s\n", btos(0));
printf("->ltos:\t%s\n", ltos(80000000l));
printf("->ftos:\t%s\n", ftos(8.5096f, 4));
printf("->dtos:\t%s\n", dtos(8.0123456789, 10));
printf("\n");
printf("->stoi:\t%d\n", stoi("1024"));
printf("->stob:\t%d\n", stob("false"));
printf("->stol:\t%ld\n", stol("80000000"));
printf("->stof:\t%f\n", stof("8.5096"));
printf("->stod:\t%.10lf\n", stod("8.0123456789"));
printf("\n");
char c;
scanf("%c", &c);
return 0;
}