Squall NTCK Posted October 10, 2004 Share Posted October 10, 2004 Voila je dois faire un petit prog de cryptographie en C, et j'ai beaucouo de mal avec un des test.... void main (void) { int cpt = 0 ; // Compteur int cle[4]; int n = 0; char temp[4]; char mot [50]; char mot2 [50]; char mot3 [50]; ..... if (mot[n]+cle[n]>'z' || mot[n]+cle[n]>'Z') { mot2[n] = mot[n]+cle[n]- 'a'; } else mot2[n] = mot[n]+cle[n]; n++; .... Voila le but du test c'est que lorsque le prog. additionne la clé ( de 0 à 9 ) et que le caractère dépasse 'z" le prog. le fasse passé à a et continue de l'incrémenté Je ne sais pas si je suis clair ou pas Link to comment Share on other sites More sharing options...
theocrite Posted October 10, 2004 Share Posted October 10, 2004 Il ne faut pas soustraire 'a', mais 26 pour enlever toutes les lettres de l'alphabet. if (mot[n]+cle[n]>'z' || mot[n]+cle[n]>'Z') Ici, ça ne fonctionne pas. Il faut que tu saches si ta lettre est une lettre minuscule ou capitale. Moi je ferais ça : if (islower(mot[n])) mot2[n] = (mot[n] + cle[n] - 'a')%26 + 'a'; else mot2[n] = (mot[n] + cle[n] - 'A')%26 + 'A'; Link to comment Share on other sites More sharing options...
Squall NTCK Posted October 11, 2004 Author Share Posted October 11, 2004 Theo Link to comment Share on other sites More sharing options...
theocrite Posted October 11, 2004 Share Posted October 11, 2004 Il fonctionne ton prog ? Link to comment Share on other sites More sharing options...
Squall NTCK Posted October 13, 2004 Author Share Posted October 13, 2004 Oui ca fonctionne nickel Link to comment Share on other sites More sharing options...
divx Posted October 15, 2004 Share Posted October 15, 2004 Tu es sur d'avoir vu en cours la notion de cast en programmation informatique ? je crois que ca peut t'aider ! Link to comment Share on other sites More sharing options...
Squall NTCK Posted October 17, 2004 Author Share Posted October 17, 2004 Oui..... j'ai vu le casting et j'ai des notions de C, mais elle remonte à 2 ans, donc dans certain cas, j'ai du mal à trouver le moyen de faire ce que je veux Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.