mirror of
https://gitlab.gwdg.de/j.hahn02/university.git
synced 2025-12-31 22:34:25 -05:00
23 lines
588 B
C
23 lines
588 B
C
#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;
|
|
}
|