C语言函数集(十三)
函数名: open
功 能: 打开一个文件用于读或写
用 法: int open(char *pathname, int access[, int permiss]);
程序例:
#include <string.h>
#include <stdio.h>
#include <fcntl.h>
#include <io.h>
int main(void)
{
int handle;
char msg[] = "Hello world";
if ((handle = open("TEST.$$$", O_CREAT | O_TEXT)) == -1)
{
perror("Error:");
return 1;
}
write(handle, msg, strlen(msg));
close(handle);
return 0;
}
函数名: outport
功 能: 输出整数到硬件端口中
用 法: void outport(int port, int value);
程序例:
#include <stdio.h>
#include <dos.h>
int main(void)
{
int value = 64;
int port = 0;
outportb(port, value);
printf("Value %d sent to port number %d\n", value, port);
return 0;
}
函数名: outportb
功 能: 输出字节到硬件端口中
用 法: void outportb(int port, char byte);
程序例:
#include <stdio.h>
#include <dos.h>
int main(void)
{
int value = 64;
int port = 0;
outportb(port, value);
printf("Value %d sent to port number %d\n", value, port);
return 0;
}
函数名: outtext
功 能: 在视区显示一个字符串
用 法: void far outtext(char far *textstring);
程序例:
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int midx, midy;
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}
midx = getmaxx() / 2;
midy = getmaxy() / 2;
/* move the C.P. to the center of the screen */
moveto(midx, midy);
/* output text starting at the C.P. */
outtext("This ");
outtext("is ");
outtext("a ");
outtext("test.");
/* clean up */
getch();
closegraph();
return 0;
}
函数名: outtextxy
功 能: 在指定位置显示一字符串
用 法: void far outtextxy(int x, int y, char *textstring);
程序例:
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int midx, midy;
/* initialize graphics and local variables */
initgraph( &gdriver, &gmode, "");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}
midx = getmaxx() / 2;
midy = getmaxy() / 2;
/* output text at the center of the screen*/
/* Note: the C.P. doesn't get changed.*/
outtextxy(midx, midy, "This is a test.");
/* clean up */
getch();
closegraph();
return 0;
}
C语言函数集(十三)相关推荐
- C语言函数集(二十一)
函数名: wherex 功 能: 返回窗口内水平光标位置 用 法: int wherex(void); 程序例: #include <conio.h> int main(void) { c ...
- C语言函数集(二十)
函数名: vfprintf 功 能: 送格式化输出到一流中 用 法: int vfprintf(FILE *stream, char *format, va_list param); 程序例: #in ...
- C语言函数集(十八)
函数名: tan 功 能: 正切函数 用 法: double tan(double x); 程序例: #include <stdio.h> #include <math.h> ...
- C语言函数集(十七)
函数名: sbrk 功 能: 改变数据段空间位置 用 法: char *sbrk(int incr); 程序例: #include <stdio.h> #include <alloc ...
- C语言函数集(十六)
函数名: raise 功 能: 向正在执行的程序发送一个信号 用 法: int raise(int sig); 程序例: #include <signal.h> int main(void ...
- C语言函数集(十五)
函数名: qsort 功 能: 使用快速排序例程进行排序 用 法: void qsort(void *base, int nelem, int width, int (*fcmp)()); 程序例: ...
- C语言函数集(十四)
函数名: parsfnm 功 能: 分析文件名 用 法: char *parsfnm (char *cmdline, struct fcb *fcbptr, int option); 程序例: #in ...
- C语言函数集(十二)
main()主函数 每一C 程序都必须有一main()函数, 可以根据自己的爱好把它放在程序的某个地方.有些程序员把它放在最前面, 而另一些程序员把它放在最后面, 无论放在哪个地方, 以下几点说明都是 ...
- C语言函数集(十一)
函数名: labs 功 能: 取长整型绝对值 用 法: long labs(long n); 程序例: #include <stdio.h> #include <math.h> ...
最新文章
- [Windows编程] 如何捕捉程序异常/crash 并生成 dump 文件
- FD.io/VPP — IPSec NAT-T
- java stringbuilder换行_初遇Java StringBuffer 和 StringBuilder 类利用 StringBuilder 给TextView实现换行处理...
- 【实验】广域网点到点协议PPP PAP CHAP的双向验证、单项认证
- dbca no protocol support
- 四则运算---Java、C语言 写法
- Java 集合系列04之 fail-fast总结
- mariadb用户群体mysql_MySQL/MariaDB用户账户管理
- 马斯克认怂和解,特斯拉股价大涨17%,市值回涨78亿美元
- 使用GHOST打包制作gho镜像文件
- 微信小程序开发https设置
- PHP强大自适应OA协同办公系统源码 含CRM客户管理系统+内部聊天工具
- 把显存用在刀刃上!17 种 pytorch 节约显存技巧
- 鸿蒙系统吹了多少年了还没出,实话实说,在鸿蒙系统上,余承东吹了几次牛都没实现 - 区块网...
- 微信视频号视频保存,微信视频号视频下载的方法
- 被吹上天的802.11ac Wave2到底好在哪?还有,Wave1哪去了?
- 微信公众号之语音接口
- CSharp学习笔记
- java与jdk版本号的区别
- Android手机通用电池校正方法