ASCII码转换

想做一个加密信息的小程序,第一个想到的办法就是用书上看到的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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值