re
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
char *my_weirddup(char *src){
|
||||
|
||||
if(src == NULL) return NULL;
|
||||
|
||||
int index = 0;
|
||||
while(*(src)){
|
||||
index ++;
|
||||
src ++;
|
||||
}
|
||||
|
||||
char *str = malloc(index + 1);
|
||||
if(str == NULL) return NULL;
|
||||
|
||||
//src = 0;
|
||||
|
||||
char lettre = ' ';
|
||||
index = 0;
|
||||
|
||||
while (*src){
|
||||
lettre = *src;
|
||||
|
||||
//maj
|
||||
if (lettre > 64 && lettre < 91){
|
||||
if (lettre == 'Z') lettre = 'A';
|
||||
else lettre += 1;
|
||||
}
|
||||
|
||||
//min
|
||||
else if (lettre > 97 && lettre < 124 ){
|
||||
|
||||
if (lettre == 'z')lettre = 'a';
|
||||
else lettre += 1;
|
||||
}
|
||||
|
||||
*str = lettre;
|
||||
src ++;
|
||||
str ++;
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
int main(){
|
||||
|
||||
printf("%s",my_weirddup("abb"));
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user