C/C++——小编谈C语言函数那些事(10)
C程序是由一组或是变量或是函数的外部对象组成的。 函数是一个自我包含的完成一定相关功能的执行代码段。下面小编和大家分享下C语言中的函数。
1. initgraph函数
initgraph函数是初始化图形系统,其用法为:void far initgraph(int far *graphdriver, int far *graphmode,char far *pathtodriver); 程序例子如下:
include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
int gdriver = DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, "");
errorcode = graphresult();
if (errorcode != grOk) {
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
line(0, 0, getmaxx(), getmaxy());
getch();
closegraph();
return 0;
}
2. intdos函数
intdos函数是通用DOS接口,其用法为:int intdos(union REGS *inregs, union REGS *outregs); 程序例子如下:
#include <stdio.h>
#include <dos.h>
/* deletes file name; returns 0 on success, nonzero on failure */
int delete_file(char near *filename)
{
union REGS regs;
int ret;
regs.h.ah = 0x41; /* delete file */
regs.x.dx = (unsigned) filename;
ret = intdos(®s, ®s);
/* if carry flag is set, there was an error */
return(regs.x.cflag ? ret : 0);
}
int main(void)
{
int err;
err = delete_file("NOTEXIST.$$$");
if (!err)
相关文档:
一 :解决C或C++中的multiple definition of问题
server.cpp
clientp2p.cpp
#include "exception.h"
#include "clientp2p.h"
clientp2p.h
中写有所有的全局变量及其初始化值
和函数声明
1.server.cpp中:
引用
:
#include "clientp2p.h"
int Main(....)
{
...
}
2.clientp ......
va系列宏的用法的一般步骤:
vsptr(char *format, ...) //切记此处的格式
{
va_list argptr;
va_start(argptr, format); //使得argptr指向以format开头的存储空间
va_arg(argptr, type); //取传递的参数
......
C程序是由一组或是变量或是函数的外部对象组成的。 函数是一个自我包含的完成一定相关功能的执行代码段。下面小编和大家分享下C语言中的函数。
1. fclose函数
fclose函数的功能是关闭一个流,其用法是:int fclose(FILE *stream); 程序例子如下:
#include <string.h& ......