This commit is contained in:
2026-02-02 04:52:09 +01:00
parent fca4d20f5a
commit 49213b1343
6 changed files with 64 additions and 54 deletions
+17 -10
View File
@@ -1,6 +1,8 @@
#include <stdlib.h>
#include <stdio.h>
char *strdup(const char *s);
char *my_weirddup(char *src){
if(src == NULL) return NULL;
@@ -10,7 +12,7 @@ char *my_weirddup(char *src){
index ++;
}
char *str = malloc(index);
char *str = malloc((index + 1) * sizeof(char));
if(str == NULL) return NULL;
//printf("test");
@@ -29,7 +31,7 @@ char *my_weirddup(char *src){
}
//min
if (lettre > 96 && lettre < 124) {
else if (lettre > 96 && lettre < 123) {
if (lettre == 'z') lettre = 'a';
else lettre ++;
}
@@ -38,22 +40,27 @@ char *my_weirddup(char *src){
index ++;
}
*(str + index + 1) = '\0';
*(str + index) = '\0';
return str;
}
//TODO MARCHE MAIS À COMPLETER
int main(int args ,char **arg){
int index = 1;
char *rslt = "";
char *rslt = NULL;
char *ic = NULL;
while(index < args){
rslt = my_weirddup(*(arg + index));
printf("%s\n",rslt);
free(rslt);
index ++;
ic = strdup(*(arg + index));
rslt = my_weirddup(ic);
if (rslt != NULL){
printf("%s\n", rslt);
free(rslt);
}
free(ic);
index ++;
}
}