67 lines
1.2 KiB
C
67 lines
1.2 KiB
C
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
|
|
char *strdup(const char *s);
|
|
|
|
char *my_weirddup(char *src){
|
|
|
|
if(src == NULL) return NULL;
|
|
|
|
int index = 0;
|
|
while(*(src + index)){
|
|
index ++;
|
|
}
|
|
|
|
char *str = malloc((index + 1) * sizeof(char));
|
|
if(str == NULL) return NULL;
|
|
|
|
//printf("test");
|
|
|
|
char lettre = ' ';
|
|
index = 0;
|
|
|
|
while (*(src + index) != '\0'){
|
|
|
|
lettre = *(src + index);
|
|
|
|
//MAJ
|
|
if (lettre > 64 && lettre < 91){
|
|
if (lettre == 'Z') lettre = 'A';
|
|
else lettre ++;
|
|
}
|
|
|
|
//min
|
|
else if (lettre > 96 && lettre < 123) {
|
|
if (lettre == 'z') lettre = 'a';
|
|
else lettre ++;
|
|
}
|
|
|
|
*(str + index) = lettre;
|
|
index ++;
|
|
}
|
|
|
|
*(str + index) = '\0';
|
|
return str;
|
|
|
|
}
|
|
|
|
int main(int args ,char **arg){
|
|
|
|
int index = 1;
|
|
char *rslt = NULL;
|
|
char *ic = NULL;
|
|
|
|
while(index < args){
|
|
|
|
ic = strdup(*(arg + index));
|
|
rslt = my_weirddup(ic);
|
|
|
|
if (rslt != NULL){
|
|
printf("%s\n", rslt);
|
|
free(rslt);
|
|
}
|
|
free(ic);
|
|
index ++;
|
|
}
|
|
}
|