This repository has been archived on 2026-05-11. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
prog-103-p-02-2030/Digby_Real_Estate/Fundamentals/my_weirddup.c
T
2026-02-02 05:05:29 +01:00

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 ; %s\n", ic ,rslt);
free(rslt);
}
free(ic);
index ++;
}
}