C/C++——小编谈C语言函数那些事(24)
C程序是由一组或是变量或是函数的外部对象组成的。 函数是一个自我包含的完成一定相关功能的执行代码段。下面小编和大家分享下C语言中的函数。
1. setvect函数
setvect函数的功能是设置中断矢量入口,其用法为:void setvect(int intr_num, void interrupt(*isr)());程序实例如下:
#include <stdio.h>
#include <dos.h>
#include <conio.h>
#define INTR 0X1C
void interrupt ( *oldhandler)(void);
int count=0;
void interrupt handler(void)
{
count++;
oldhandler();
}
int main(void)
{
oldhandler = getvect(INTR);
setvect(INTR, handler);
while (count < 20)
printf("count is %d\n",count);
setvect(INTR, oldhandler);
return 0;
}
2. setverify函数
setverify函数的功能是设置验证状态,其用法为void setverify(int value);程序实例代码如下:
#include <stdio.h>
#include <conio.h>
#include <dos.h>
int main(void)
{
int verify_flag;
printf("Enter 0 to set verify flag off\n");
printf("Enter 1 to set verify flag on\n");
verify_flag = getch() - 0;
setverify(verify_flag);
if (getverify())
printf("DOS verify flag is on\n");
else
printf("DOS verify flag is off\n");
return 0;
}
3. setviewport函数
setviewport函数的功能是为图形输出设置当前视口, 其用法为:void far setviewport(int left, int top, int right,int bottom, int clipflag);程序实例代码如下:
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#define CLIP_ON 1&n
相关文档:
C程序是由一组或是变量或是函数的外部对象组成的。 函数是一个自我包含的完成一定相关功能的执行代码段。下面小编和大家分享下C语言中的函数。
1. registerbgidriver函数
registerbgidriver函数的功能是登录已连接进来的图形驱动程序代码,其用法为:int registerbgidriver(void(*driver)(void ......
C程序是由一组或是变量或是函数的外部对象组成的。 函数是一个自我包含的完成一定相关功能的执行代码段。下面小编和大家分享下C语言中的函数。
1. raise函数
raise函数的功能是向正在执行的程序发送一个信号,其用法为:int raise(int sig);程序实例如下:
#include <signal.h& ......
C程序是由一组或是变量或是函数的外部对象组成的。 函数是一个自我包含的完成一定相关功能的执行代码段。下面小编和大家分享下C语言中的函数。
1. setfillpatterne函数
setfillpatterne函数的功能是选择用户定义的填充模式,其用法为:void far setfillpattern(char far *upattern, int ......
题目:输入三个字符串a,b和c,将a中b的第一次出现替换为c。
代码:
#include <iostream.h>
#include <string.h>
/*字符串替换,第一个参数为原串,第二个参数为要匹配的子串
第三个参数为要替换的第一个子串中包含第二个子串的部分*/
char *strReplace(char *str1,char *str2,char *str3);
void main() ......
C程序是由一组或是变量或是函数的外部对象组成的。 函数是一个自我包含的完成一定相关功能的执行代码段。下面小编和大家分享下C语言中的函数。
1. setmem函数
setmem函数的功能是存值到存储区,其用法为:void setmem(void *addr, int len, char value);程序实例如下:
#include <stdio.h& ......