#include #include "ascii.h" ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void ascii() { char ascii[100] = {}, lettre = 0; int i = 0, y = 33, choix = 0; printf("~~ ASCII converter v1.0 ~~\n\n\n\n"); printf("1- Affichage manuel\n2- Afficher Table ASCII\n3- Quitter\n\n"); printf("Choix du mode : "); scanf("%d", &choix); if(choix == 1) mode(); else if(choix == 2) tableAscii(); else printf("A bientot !\n\n"); } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void mode() { int choix = 0; char lettre = 0; printf("\nAffichage manuel :\n\n\n"); printf("1- Lettre ---> code ASCII\n2- Code ASCII ---> Lettre\n\n"); printf("Choississez une option : "); scanf("%d", &choix); fflush(stdin); if(choix == 1) { printf("\nEntrez une lettre : "); lettre = getchar(); while(getchar() != '\n'); printf("\n\nLe code ASCII correspondant a la lettre %c est : %d", lettre, lettre); } else if(choix == 2) { printf("Entrez un nombre compris entre 33 et 127 : "); scanf("%d", &lettre); printf("\n\nLa lettre correspondant au code ASCII %d est : %c", lettre, lettre); } } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int tableAscii() { char ascii[100] = {}; int y = 33, i = 0, choix = 0; printf("~~ Table ASCII ~~\n\n\n\n"); printf("Lettre ------- Dec\n"); for(y; y!=126; y++) { i++; ascii[i] = y; printf("%c ------------ %d\n", ascii[i], ascii[i]); } printf("\n\n1- Oui\n2- Non\n\n"); printf("Voulez-vous enregistrer ? : "); scanf("%d", &choix); if(choix == 1) enregistrer(ascii); else printf("A bientot !\n"); } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void enregistrer(char *ascii) { FILE *fichier = NULL; int i = 1; fichier = fopen("Table ASCII.txt", "w"); fprintf(fichier, "~~ Table ASCII ~~\n\n\n\n"); fprintf(fichier, "Lettre ------- Dec\n"); for(i; i<94; i++) { fprintf(fichier, "%c ------------ %d\n", ascii[i], ascii[i]); } fclose(fichier); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////