转载的一些常用的C函数,还有些用途
来源:互联网 发布:java开源周报管理系统 编辑:程序博客网 时间:2024/06/05 02:35
C系统函数库些许
--------------------------------------------------------------------------------
原型:extern void clrscr(void);
extern void ClearScreen(void);
用法:#i nclude <system.h>
功能:清屏
说明:清除屏幕缓冲区及液晶显示缓冲区
光标位置回到屏幕左上角。
举例:
// clrscr.c
#i nclude <system.h>
main()
{
clrscr();
textmode(0x00);
printf("Press a key");
getchar();
ClearScreen();
printf("Another Screen");
-------------------------------------------------------------------------------- 原型:extern int getkey(void);
用法:#i nclude <system.h>
功能:读键
说明:功能同getchar
举例:
// getkey.c
#i nclude <system.h>
main()
{
int c;
clrscr();
printf("Press key...");
while((c=getkey())!='Q')
{
clrscr();
printf("key: %c/nvalue: %x",c,c);
-------------------------------------------------------------------------------- 原型:extern void sleep(unsigned int sec);
用法:#i nclude <system.h>
功能:短暂延时
说明:延时sec秒
举例:
// sleep.c
#i nclude <system.h>
main()
{
int c;
clrscr();
printf("/nHello, world!");
sleep(1);
clrscr();
printf("/nHi, guys");
-------------------------------------------------------------------------------- 原型:extern void delay(unsigned int msec);
用法:#i nclude <system.h>
功能:短暂延时
说明:延时msec*4毫秒
举例:
// delay.c
#i nclude <system.h>
main()
{
int c;
clrscr();
printf("/nHello, world!");
delay(250); // 250*4=1000msec=1sec
clrscr();
printf("/nHi, guys");
-------------------------------------------------------------------------------- 原型:extern void line(int left, int top, int right, int bottom, int mode);
用法:#i nclude <system.h>
功能:在屏幕上画直线
说明:(left,top)和(right,bottom)指定直线的两个端点坐标。mode决定划线的模式。
超出屏幕的线将被裁端。
mode值的含义:
mode=0:清除方式
=1:正常方式
=2:取反方式
举例:
// line.c
#i nclude <system.h>
main()
{
clrscr();
move(10,10); // hide cursor
block(20,10,100,40,1);
line(1,1,111,47,1); // from top left to bottom right
line(1,47,111,1,0); // from bottom left to top right
line(112/2,1,112/2,47,2); // line vertically at the middle of the LCD
-------------------------------------------------------------------------------- 原型:extern int kbhit(void);
用法:#i nclude <stdio.h>
功能:检测按键
说明:检测键盘是否有键按下。
如果有键按下,则返回对应键值;否则返回零。
kbhit不等待键盘按键。无论有无按键都会立即返回。
举例:
// kbhit.c
#i nclude <stdio.h>
main()
{
int i=0;
clrscr();
while(!kbhit())
{
clrscr();
printf("%05d",i++);
}
clrscr();
printf("End.");
getchar();
return 0;
} 无键按下时,返回零;有键按下时,返回的不是键值,而是 -1。 要取得键值,可以在循环里用 getch() 来接收。
原型:extern int getchar(void);
用法:#i nclude <ctype.h>
功能:读键
说明:从键盘上读取一个键,并返回该键的键值
getch是到getchar的宏定义
举例:
// getchar.c
#i nclude <stdio.h>
main()
{
int c;
clrscr();
printf("Press key...");
while((c=getchar())!='Q')
{
clrscr();
printf("key: %c/nvalue: %x",c,c);
}
- 转载的一些常用的C函数,还有些用途
- 关于typedef和指针函数的用法的一些尝试,依然有些不求甚解-C语言
- 一些特殊用途的C语句
- 一些不安全的常用的C函数
- 一些常用的C语言函数源代码
- (C)string的一些常用函数原型
- c语言中一些常用的函数
- C/C++ 常用的一些函数
- 一些c中常用的功能函数
- [C++] inline函数_内联函数的一些总结【转载】
- 【c语言】函数指针的用途
- 关于2017开始的新工作想法与一些学习进步方向还有些阶段目标
- dynamic_cast 的一些用途
- dynamic_cast 的一些用途
- UIApplacation的一些用途
- UITextView 的一些用途
- 常用c++的一些转载
- 一个控制台输出彩色字符的printf,还有些改颜色的函数
- 【转】 用EXPLAIN PLAN 分析SQL语句
- 输入法的添加(mtk平台t9,zi之外的输入法)
- 初学symbian 对话框我见
- 是Intel的编译器出问题了吗?
- 09年度上学期形势政策
- 转载的一些常用的C函数,还有些用途
- 新的使用基于GPU粒子的火焰和爆炸效果
- 使用Intel编译器获得一致的浮点数值计算结果
- Pyke 简介 (6) :安装 Pyke
- java 视频处理 ffmpeg+mencoder
- QT解决通过菜单方式无法让QDockWidget 显示和隐藏
- maven项目管 配置
- 关于Visual Studio工具插件RockScroll兼容性的问题
- 只读数据区