mirror of
https://gitlab.gwdg.de/j.hahn02/university.git
synced 2026-01-01 06:44:25 -05:00
cleanup
This commit is contained in:
22
S1/GdCP/code.c
Normal file
22
S1/GdCP/code.c
Normal file
@@ -0,0 +1,22 @@
|
||||
#include<string.h>
|
||||
#include<ctype.h>
|
||||
|
||||
char* convert_message(const char *message, char receiver) {
|
||||
char *out = strdup(message);
|
||||
if (receiver != 'M' && receiver != 'L') return "Mit dir schreib ich nicht!";
|
||||
int c = 0;
|
||||
for (int i = 0; message[i] != '\0'; i++) {
|
||||
if (isalpha(message[i])) {
|
||||
if (receiver == 'M') {
|
||||
if (c % 2 == 1) out[i] = toupper(message[i]);
|
||||
else out[i] = tolower(message[i]);
|
||||
}
|
||||
else {
|
||||
if (c % 2 == 0) out[i] = toupper(message[i]);
|
||||
else out[i] = tolower(message[i]);
|
||||
}
|
||||
c++;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
Reference in New Issue
Block a user