From a7ea5df85529b6383d3c29ef2eec3dc080d56ad9 Mon Sep 17 00:00:00 2001 From: Philippe Pittoli Date: Thu, 27 Oct 2011 18:22:48 +0200 Subject: [PATCH] a lot of changes --- C_Language/{test.c => cd.c} | 0 C_Language/lirecharl.c | 37 ++++++++ C_Language/minuscule.c | 25 ++++++ C_Language/miroir.c | 31 +++++++ C_Language/palindrome.c | 31 +++++++ .../Exemple_curses/essaiCurses | Bin .../Exemple_curses/essaiCurses.doc | Bin .../Exemple_curses/essaiCurses.pdf | Bin .../Exemple_curses/essaicurses.c | 0 .../Exemples_semaphores/a.out | Bin .../Exemples_semaphores/creaZ | Bin .../Exemples_semaphores/creaZ.c | 0 .../Exemples_semaphores/ecrireZ.c | 0 .../Exemples_semaphores/ecrireZ_Sem | Bin .../Exemples_semaphores/ecrireZ_Sem.c | 0 .../Exemples_semaphores/lireZ | Bin .../Exemples_semaphores/lireZ.c | 0 .../Exemples_semaphores/raZ | Bin .../Exemples_semaphores/raZ.c | 0 .../Exemples_semaphores/sema.c | 0 .../Exemples_semaphores/sema.h | 0 .../Exemples_semaphores/sema.o | Bin .../FileeDeMessage/msgCons.c | 0 .../FileeDeMessage/msgProd.c | 0 .../FileeDeMessage/nom2_de_fichier_existant | 0 .../FileeDeMessage/test_msgctl.c | 0 .../essaiCurses.pdf | Bin .../manuel_2009.pdf | Bin .../wtest6.c.pdf | Bin C_Language/squeeze.c | 7 -- C_Language/tout.c | 85 ------------------ 31 files changed, 124 insertions(+), 92 deletions(-) rename C_Language/{test.c => cd.c} (100%) create mode 100644 C_Language/lirecharl.c create mode 100644 C_Language/minuscule.c create mode 100644 C_Language/miroir.c create mode 100644 C_Language/palindrome.c rename C_Language/{TP_SYS => semaphores_manuel_exemples}/Exemple_curses/essaiCurses (100%) rename C_Language/{TP_SYS => semaphores_manuel_exemples}/Exemple_curses/essaiCurses.doc (100%) rename C_Language/{TP_SYS => semaphores_manuel_exemples}/Exemple_curses/essaiCurses.pdf (100%) rename C_Language/{TP_SYS => semaphores_manuel_exemples}/Exemple_curses/essaicurses.c (100%) rename C_Language/{TP_SYS => semaphores_manuel_exemples}/Exemples_semaphores/a.out (100%) rename C_Language/{TP_SYS => semaphores_manuel_exemples}/Exemples_semaphores/creaZ (100%) rename C_Language/{TP_SYS => semaphores_manuel_exemples}/Exemples_semaphores/creaZ.c (100%) rename C_Language/{TP_SYS => semaphores_manuel_exemples}/Exemples_semaphores/ecrireZ.c (100%) rename C_Language/{TP_SYS => semaphores_manuel_exemples}/Exemples_semaphores/ecrireZ_Sem (100%) rename C_Language/{TP_SYS => semaphores_manuel_exemples}/Exemples_semaphores/ecrireZ_Sem.c (100%) rename C_Language/{TP_SYS => semaphores_manuel_exemples}/Exemples_semaphores/lireZ (100%) rename C_Language/{TP_SYS => semaphores_manuel_exemples}/Exemples_semaphores/lireZ.c (100%) rename C_Language/{TP_SYS => semaphores_manuel_exemples}/Exemples_semaphores/raZ (100%) rename C_Language/{TP_SYS => semaphores_manuel_exemples}/Exemples_semaphores/raZ.c (100%) rename C_Language/{TP_SYS => semaphores_manuel_exemples}/Exemples_semaphores/sema.c (100%) rename C_Language/{TP_SYS => semaphores_manuel_exemples}/Exemples_semaphores/sema.h (100%) rename C_Language/{TP_SYS => semaphores_manuel_exemples}/Exemples_semaphores/sema.o (100%) rename C_Language/{TP_SYS => semaphores_manuel_exemples}/FileeDeMessage/msgCons.c (100%) rename C_Language/{TP_SYS => semaphores_manuel_exemples}/FileeDeMessage/msgProd.c (100%) rename C_Language/{TP_SYS => semaphores_manuel_exemples}/FileeDeMessage/nom2_de_fichier_existant (100%) rename C_Language/{TP_SYS => semaphores_manuel_exemples}/FileeDeMessage/test_msgctl.c (100%) rename C_Language/{TP_SYS => semaphores_manuel_exemples}/essaiCurses.pdf (100%) rename C_Language/{TP_SYS => semaphores_manuel_exemples}/manuel_2009.pdf (100%) rename C_Language/{TP_SYS => semaphores_manuel_exemples}/wtest6.c.pdf (100%) delete mode 100644 C_Language/tout.c diff --git a/C_Language/test.c b/C_Language/cd.c similarity index 100% rename from C_Language/test.c rename to C_Language/cd.c diff --git a/C_Language/lirecharl.c b/C_Language/lirecharl.c new file mode 100644 index 0000000..428dce0 --- /dev/null +++ b/C_Language/lirecharl.c @@ -0,0 +1,37 @@ +#include +#include +#include +#include + +// lire un nombre de caractères donné par n +int lirechl(char *s, int n); +int main(int argc, char **argv) +{ + if(argc < 2) + { + fprintf(stderr,"Usage : %s number\n",argv[0]); + exit(EXIT_FAILURE); + } + int n = atoi(argv[1]); + char * s = malloc(sizeof(char) * n + 1); + int i = 0; + i = lirechl(s,n); + printf("read : %d char, sentence : %s \n",i , s); + + return EXIT_SUCCESS; +} + +int lirechl(char *s, int n) +{ + int i, c; + i=0; + while( i < n && ( c = getchar() ) != '\n' ) + s[i++] = c ; + + s[i] = '\0'; + + if ( c != '\n' ) + while ( getchar() != '\n' ); + + return i; +} diff --git a/C_Language/minuscule.c b/C_Language/minuscule.c new file mode 100644 index 0000000..58f1983 --- /dev/null +++ b/C_Language/minuscule.c @@ -0,0 +1,25 @@ +#include +#include +#include + +// met en minuscule la chaîne +void minuscule(char *); + +int main(int argc, char * argv[]) +{ + if(argc < 2) + { + printf("Usage : %s SenTeNCe\n",argv[0]); + exit(EXIT_FAILURE); + } + char * s = malloc(sizeof(char) * strlen(argv[1])); + s = strcpy(s,argv[1]); + minuscule(s); + printf("%s\n", s); + return EXIT_SUCCESS; +} + +void minuscule(char * s) +{ + while(*s++ && (*s = tolower(*s))); +} diff --git a/C_Language/miroir.c b/C_Language/miroir.c new file mode 100644 index 0000000..97e37be --- /dev/null +++ b/C_Language/miroir.c @@ -0,0 +1,31 @@ +#include +#include +#include + +// on donne s et t sera le miroir +void miroir ( char *s, char *t); + +int main(int argc, char * argv[]) +{ + if ( argc != 2 ) + { + printf("Usage: %s sentence \n", *argv); + exit(EXIT_FAILURE); + } + char t[strlen(argv[1])]; + miroir(argv[1],t); + printf("%s :: %s\n",argv[1],t); + return EXIT_SUCCESS; +} + +void miroir ( char *s, char *t) +{ + int i=0, taille = strlen(s); + t[taille] = '\0'; + taille--; + while((taille - i) >= 0) + { + t[taille-i]=s[i]; + i++; + } +} diff --git a/C_Language/palindrome.c b/C_Language/palindrome.c new file mode 100644 index 0000000..ec923e1 --- /dev/null +++ b/C_Language/palindrome.c @@ -0,0 +1,31 @@ +#include +#include +#include + +int palindrome(char *); + +int main(int argc, char * argv[]) +{ + int rep = palindrome(argv[1]); + if(rep==1) + printf("Cette phrase est un palindrome\n"); + else + printf("Cette phrase n'est pas un palindrome\n"); + + return EXIT_SUCCESS; +} + +int palindrome(char *s) +{ + int i=0,res = 1; + char t[strlen(s)]; + squeeze(s,t,' '); + minuscule(t); + while(i -#include -#include -#include - -void miroir ( char *s, char *t); // on donne s et t sera le miroir -void squeeze( char *s , char *t, char c); // on donne s et t sera la chaine sans le caractère c -int lirechl(char *s, int n); // lire un nombre de caractères donné par n -int palindrome(char *); // 1 si vrai 0 sinon -void minuscule(char *); // met en minuscule la chaîne -int main(int argc, char **argv) -{ - if ( argc != 2 ) - { - printf("Usage: %s sentence \n", *argv); - exit(2); - } - char *s = argv[1]; - char t[strlen(s)]; - miroir(s,t); - printf("%s :: %s\n",s,t); - - int rep = palindrome(s); - if(rep==1) - printf("Cette phrase est un palindrome\n"); - else - printf("Cette phrase n'est pas un palindrome\n"); -} -void miroir ( char *s, char *t) -{ - int i=0, taille = strlen(s); - t[taille] = '\0'; - taille--; - while((taille - i) >= 0) - { - t[taille-i]=s[i]; - i++; - } -} -int palindrome(char *s) -{ - int i=0,res = 1; - char t[strlen(s)]; - squeeze(s,t,' '); - minuscule(t); - while(i