1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| #include <stdio.h>
#include <stdlib.h>
FILE *fopen(const char NomFichier, const char ModeOuverture ) ;
int fclose(FILE* pointeurSurFichier);
const int DECALAGE = 5;
const int MINU = 0;
const int MAJ = 1;
//Fonction de cryptage :
void crypt(char *pointeur_chaine)
{
int indicateur;
if(*pointeur_chaine>='a' && *pointeur_chaine<='z')
indicateur=MINU;
else if(*pointeur_chaine>='A' && *pointeur_chaine<='Z')
indicateur=MAJ;
else return;
*pointeur_chaine = *pointeur_chaine + DECALAGE;
if((indicateur==MINU && *pointeur_chaine>'z')
|| (indicateur==MAJ && *pointeur_chaine>'Z'))
*pointeur_chaine = *pointeur_chaine -26;
}
void main()
{
FILE * source = fopen("texte.txt","r");
FILE * crypte = fopen("crypte.txt","w");
char *pointeur = NULL;
int compteur;
while( pointeur_chaine = fgetc( texte ) && caractere != EOF )
{
crypt pointeur_chaine;
fputc(crypt, crypte);
}
fclose(texte);
fclose(crypte);
getch();
return 0;
} |
Partager