B
bpascal123
It is a waste of time to learn the wrong what and then the right way.
To the OP: consider getting a copy of K&R2.
Hi,
Some have been requestiong where i was getting my tut from. I was
reluctant to answer because it's in french and for many it wouldn't
mean much.
Here it is : http://www.ltam.lu/Tutoriel_Ansi_C/
look at application 8.8
And the solution to the application is there : http://www.ltam.lu/Tutoriel_Ansi_C/homesol.htm
Often for this tutorial i find the solution from the author not
applicable outside this tutorial. Even if for now, i don't find
exciting calling that DOS or Unix terminal to see the outputs of what
i'm learning, i hope soon to apply this on more human stuff maybe on
cell phones or whatever...
That's why i'd like to add some more stuff that would make it look
more real if i would use it outside this tutorial.
In the 8.8, the solution works well with little changes from what is
published (maybe a long time ago) :
#include <stdio.h>
#include <string.h>
main()
{
/* Déclarations */
char VERB[20]; /* chaîne contenant le verbe */
char AFFI[30]; /* chaîne pour l'affichage */
int L; /* longueur de la chaîne */
/* Saisie des données */
printf("Verbe : ");
fgets(VERB, 20, stdin) ;
/* Contrôler s'il s'agit d'un verbe en 'er' */
L=strlen(VERB);
if ((VERB[L-3]!='e') || (VERB[L-2]!='r'))
puts("\aCe n'est pas un verbe du premier groupe.!");
else
{
/* Couper la terminaison 'er'. */
VERB[L-3]='\0';
/* Conjuguer ... */
AFFI[0]='\0';
strcat(AFFI, "je ");
strcat(AFFI, VERB);
strcat(AFFI, "e");
puts(AFFI);
}
return 0;
}
It just prints one pronoun otherwise you'd have to write the last
block down from "/*conjuguer ...*/" as many time as there are
pronouns.
I don't find this very efficient when a loop can tweak it and print
all pronouns.
I understand the author did just want to focus on string.h functions.
Because i'm spending 40 % of my time learning by heart, blocks of
structures and functions,
40 % doing applications from the tutorial above,
10 % reading and browsing the web for information
and the last 10 % locating bugs.
Learning by heart is special but i'm lazy and i kinda find it easier
than starting an application from scratch... If i find myself a way
to achieve an application from this tutorial, let say with 2 more
loops and 1 or 2 more if (my code is heavier than the author's) then,
i find it less rewarding as when i can apply something i have learned
by heart and it works.
Pascal