Dotcpp  >  编程教程  >  ctype.h头文件  >  C语言toascii()函数:把一个字符转换为ASCII

C语言toascii()函数:把一个字符转换为ASCII

点击打开在线编译器,边学边练

函数名: toascii

头文件:<ctype.h>

函数原型:  int toascii(int ch);

功 能: 把一个字符转换为ASCII,其实就是把八位二进制的最高变成0  

参数: int ch  待转换的字符

返回值:  返回转换后的字符


程序例: 把一个非ASCII字符转换为ASCII字符

#include<ctype.h>

#include<stdio.h>

int main(){

   int ch1,ch2;

   ch1='a'+128;

   ch2=toascii(ch1);

   printf("transform %c  to %c.\n",ch1,ch2);      

   return 0;  

}

 

运行结果:

transform ? to a.



本文固定URL:https://www.dotcpp.com/course/445

C语言函数库
assert.h头文件
ctype.h头文件
float.h头文件
io.h头文件
math.h头文件
mem.h头文件
setjmp.h头文件
stdio.h头文件
stdlib.h头文件
sigal.h头文件
string.h头文件
time.h头文件
Dotcpp在线编译      (登录可减少运行等待时间)