ASCII码转换

来源:互联网 发布:上古世纪捏脸数据在那 编辑:程序博客网 时间:2024/05/21 17:52

想做一个加密信息的小程序,第一个想到的办法就是用书上看到的ASCII码,虽然不是很成功。还是留作纪念吧。

/************************* *ASCII transformation   * *                 by:ZCB* *************************/#include<stdio.h>#include<stdlib.h>int main(void){    int a = 0;    int b = 0;    char c = 0;    printf("If you want to convert a decimal number to ASCII characters,please input 1.\n");    printf("If you want to convert ASCII characters to a decimal number,please input 2.\n");    scanf("%d",&a);    if(a == 1)    {        printf("Now we will convert a decimal number to ASCII characters.\nPlease input a decimal number.\n");        scanf("%d",&b);        if(b >= 0&&b <= 127)            printf("%c",b);        else            printf("You are so naughty.\nPlease input 1 or 2 next time.\n");    }    else if(a == 2)    {        printf("Now we will convert ASCII characters to a decimal number.\nPlease input ASCII characters.\n");        fflush(stdin);        scanf("%c",&c);        if(c >= (char)0&&c <= (char)127)            printf("%d",c);        else            printf("You are so naughty.\nPlease input 1 or 2 next time.\n");    }    else    {        printf("You are so naughty.\nPlease input 1 or 2 next time.\n");    }    system("pause");    return 0;}
0 0
原创粉丝点击