arret
This commit is contained in:
@@ -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 ++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user