conjugaison.c
00001 #include <stdio.h>
00002 #include <stdlib.h>
00003 #include <string.h>
00004
00005 struct correspondance {
00006 char pronom[15];
00007 char suffixe[4];
00008 };
00009
00010 int main(int argc, char * argv[])
00011 {
00012 if (argc != 2) {
00013 printf("usage: %s verbe\n",argv[0]);
00014 return EXIT_FAILURE;
00015 }
00016 size_t i, n = strlen(argv[1]);
00017 if ((n < 4) || (argv[1][n-2] != 'e') || (argv[1][n-1] != 'r')) {
00018 printf("Ce n'est pas un verbe du premier groupe!\n");
00019 return EXIT_FAILURE;
00020 }
00021 struct correspondance tab[] = {
00022 {"je", "e"}, {"tu", "es"}, {"il ou elle", "e"},
00023 {"nous", "ons"}, {"vous", "ez"}, {"ils ou elles", "ent"},
00024 };
00025 char * base_verbe = (char *) malloc((n-2+1)*sizeof(char));
00026 strncpy(base_verbe, argv[1], n-2);
00027 base_verbe[n-2] = '\0';
00028 for (i=0; i<sizeof(tab)/sizeof(struct correspondance); i++)
00029 printf("%s %s%s\n", tab[i].pronom, base_verbe, tab[i].suffixe);
00030 return 0;
00031 }
00032
00033
00034
00035
00036