⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1.txt

📁 A.执行SPLIB B.执行SPDOS C.装载拼音模块D.装载五笔字型输入模块32.在汉字输入状态下
💻 TXT
📖 第 1 页 / 共 5 页
字号:
用 法: struct COUNTRY *country(int countrycode, struct country *country); 
程序例: 

#include <dos.h> 
#include <stdio.h> 

#define USA 0 

int main(void) 
{ 
struct COUNTRY country_info; 

country(USA, &country_info); 
printf("The currency symbol for the USA is: %s\n", 
country_info.co_curr); 
return 0; 
} 




函数名: cprintf 
功 能: 送格式化输出至屏幕 
用 法: int cprintf(const char *format[, argument, ...]); 
程序例: 

#include <conio.h> 

int main(void) 
{ 
/* clear the screen */ 
clrscr(); 

/* create a text window */ 
window(10, 10, 80, 25); 

/* output some text in the window */ 
cprintf("Hello world\r\n"); 

/* wait for a key */ 
getch(); 
return 0; 
} 




函数名: cputs 
功 能: 写字符到屏幕 
用 法: void cputs(const char *string); 
程序例: 

#include <conio.h> 

int main(void) 
{ 
/* clear the screen */ 
clrscr(); 

/* create a text window */ 
window(10, 10, 80, 25); 

/* output some text in the window */ 
cputs("This is within the window\r\n"); 

/* wait for a key */ 
getch(); 
return 0; 
} 




函数名: _creat creat 
功 能: 创建一个新文件或重写一个已存在的文件 
用 法: int creat (const char *filename, int permiss); 
程序例: 

#include <sys\stat.h> 
#include <string.h> 
#include <fcntl.h> 
#include <io.h> 

int main(void) 
{ 
int handle; 
char buf[11] = "0123456789"; 

/* change the default file mode from text to binary */ 
_fmode = O_BINARY; 

/* create a binary file for reading and writing */ 
handle = creat("DUMMY.FIL", S_IREAD | S_IWRITE); 

/* write 10 bytes to the file */ 
write(handle, buf, strlen(buf)); 

/* close the file */ 
close(handle); 
return 0; 
} 


函数名: creatnew 
功 能: 创建一个新文件 
用 法: int creatnew(const char *filename, int attrib); 
程序例: 

#include <string.h> 
#include <stdio.h> 
#include <errno.h> 
#include <dos.h> 
#include <io.h> 

int main(void) 
{ 
int handle; 
char buf[11] = "0123456789"; 

/* attempt to create a file that doesn't already exist */ 
handle = creatnew("DUMMY.FIL", 0); 

if (handle == -1) 
printf("DUMMY.FIL already exists.\n"); 
else 
{ 
printf("DUMMY.FIL successfully created.\n"); 
write(handle, buf, strlen(buf)); 
close(handle); 
} 
return 0; 
} 




函数名: creattemp 
功 能: 创建一个新文件或重写一个已存在的文件 
用 法: int creattemp(const char *filename, int attrib); 
程序例: 

#include <string.h> 
#include <stdio.h> 
#include <io.h> 

int main(void) 
{ 
int handle; 
char pathname[128]; 

strcpy(pathname, "\\"); 

/* create a unique file in the root directory */ 
handle = creattemp(pathname, 0); 

printf("%s was the unique file created.\n", pathname); 
close(handle); 
return 0; 
} 




函数名: cscanf 
功 能: 从控制台执行格式化输入 
用 法: int cscanf(char *format[,argument, ...]); 
程序例: 

#include <conio.h> 

int main(void) 
{ 
char string[80]; 

/* clear the screen */ 
clrscr(); 

/* Prompt the user for input */ 
cprintf("Enter a string with no spaces:"); 

/* read the input */ 
cscanf("%s", string); 

/* display what was read */ 
cprintf("\r\nThe string entered is: %s", string); 
return 0; 
} 




函数名: ctime 
功 能: 把日期和时间转换为字符串 
用 法: char *ctime(const time_t *time); 
程序例: 

#include <stdio.h> 
#include <time.h> 

int main(void) 
{ 
time_t t; 

time(&t); 
printf("Today's date and time: %s\n", ctime(&t)); 
return 0; 
} 




函数名: ctrlbrk 
功 能: 设置Ctrl-Break处理程序 
用 法: void ctrlbrk(*fptr)(void); 
程序例: 

#include <stdio.h> 
#include <dos.h> 

#define ABORT 0 

int c_break(void) 
{ 
printf("Control-Break pressed. Program aborting ...\n"); 
return (ABORT); 
} 

int main(void) 
{ 
ctrlbrk(c_break); 
for(;;) 
{ 
printf("Looping... Press <Ctrl-Break> to quit:\n"); 
} 
return 0; 
}  

--------------------------------------------------------------------------------
 

 
 
C语言库函数(D类字母) 
AiY.CN 收集整理 (2001-07-27 10:00:00) 
函数名: delay 
功 能: 将程序的执行暂停一段时间(毫秒) 
用 法: void delay(unsigned milliseconds); 
程序例: 
/* Emits a 440-Hz tone for 500 milliseconds */ 
#include <dos.h> 
int main(void) 
{ 
sound(440); 
delay(500); 
nosound(); 

return 0; 
} 



函数名: delline 
功 能: 在文本窗口中删去一行 
用 法: void delline(void); 
程序例: 

#include <conio.h> 

int main(void) 
{ 
clrscr(); 
cprintf("The function DELLINE deletes \ 
the line containing the\r\n"); 
cprintf("cursor and moves all lines \ 
below it one line up.\r\n"); 
cprintf("DELLINE operates within the \ 
currently active text\r\n"); 
cprintf("window. Press any key to \ 
continue . . ."); 
gotoxy(1,2); /* Move the cursor to the 
second line and first column */ 
getch(); 

delline(); 
getch(); 

return 0; 
} 


函数名: detectgraph 
功 能: 通过检测硬件确定图形驱动程序和模式 
用 法: void far detectgraph(int far *graphdriver, int far *graphmode); 
程序例: 

#include <graphics.h> 
#include <stdlib.h> 
#include <stdio.h> 
#include <conio.h> 

/* names of the various cards supported */ 
char *dname[] = { "requests detection", 
"a CGA", 
"an MCGA", 
"an EGA", 
"a 64K EGA", 
"a monochrome EGA", 
"an IBM 8514", 
"a Hercules monochrome", 
"an AT&T 6300 PC", 
"a VGA", 
"an IBM 3270 PC" 
}; 

int main(void) 
{ 
/* returns detected hardware info. */ 
int gdriver, gmode, errorcode; 

/* detect graphics hardware available */ 
detectgraph(&gdriver, &gmode); 

/* read result of detectgraph call */ 
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 */ 
} 

/* display the information detected */ 
clrscr(); 
printf("You have %s video display \ 
card.\n", dname[gdriver]); 
printf("Press any key to halt:"); 
getch(); 
return 0; 
} 




函数名: difftime 
功 能: 计算两个时刻之间的时间差 
用 法: double difftime(time_t time2, time_t time1); 
程序例: 

#include <time.h> 
#include <stdio.h> 
#include <dos.h> 
#include <conio.h> 

int main(void) 
{ 
time_t first, second; 

clrscr(); 
first = time(NULL); /* Gets system 
time */ 
delay(2000); /* Waits 2 secs */ 
second = time(NULL); /* Gets system time 
again */ 

printf("The difference is: %f \ 
seconds\n",difftime(second,first)); 
getch(); 

return 0; 
} 



函数名: disable 
功 能: 屏蔽中断 
用 法: void disable(void); 
程序例: 

/***NOTE: This is an interrupt service 
routine. You cannot compile this program 
with Test Stack Overflow turned on and 
get an executable file that operates 
correctly. */ 

#include <stdio.h> 
#include <dos.h> 
#include <conio.h> 

#define INTR 0X1C /* The clock tick 
interrupt */ 

void interrupt ( *oldhandler)(void); 

int count=0; 

void interrupt handler(void) 
{ 
/* disable interrupts during the handling of 
the interrupt */ 
disable(); 
/* increase the global counter */ 
count++; 
/* reenable interrupts at the end of the 
handler */ 
enable(); 
/* call the old routine */ 
oldhandler(); 
} 

int main(void) 
{ 
/* save the old interrupt vector */ 
oldhandler = getvect(INTR); 

/* install the new interrupt handler */ 
setvect(INTR, handler); 

/* loop until the counter exceeds 20 */ 
while (count < 20) 
printf("count is %d\n",count); 

/* reset the old interrupt handler */ 
setvect(INTR, oldhandler); 

return 0; 
} 

函数名: div 
功 能: 将两个整数相除, 返回商和余数 
用 法: div_t (int number, int denom); 
程序例: 

#include <stdlib.h> 
#include <stdio.h> 

div_t x; 

int main(void) 
{ 
x = div(10,3); 
printf("10 div 3 = %d remainder %d\n", x.quot, x.rem); 

return 0; 
} 



函数名: dosexterr 
功 能: 获取扩展DOS错误信息 
用 法: int dosexterr(struct DOSERR *dblkp); 
程序例: 

#include <stdio.h> 
#include <dos.h> 

int main(void) 
{ 
FILE *fp; 
struct DOSERROR info; 

fp = fopen("perror.dat","r"); 
if (!fp) perror("Unable to open file for 
reading"); 
dosexterr(&info); 

printf("Extended DOS error \ 
information:\n"); 
printf(" Extended error: \ 
%d\n",info.exterror); 
printf(" Class: \ 
%x\n",info.class); 
printf(" Action: \ 
%x\n",info.action); 
printf(" Error Locus: \ 
%x\n",info.locus); 

return 0; 
} 



函数名: dostounix 
功 能: 转换日期和时间为UNIX时间格式 
用 法: long dostounix(struct date *dateptr, struct time *timeptr); 
程序例: 

#include <time.h> 
#include <stddef.h> 
#include <dos.h> 
#include <stdio.h> 

int main(void) 
{ 
time_t t; 
struct time d_time; 
struct date d_date; 
struct tm *local; 

getdate(&d_date); 
gettime(&d_time); 

t = dostounix(&d_date, &d_time); 
local = localtime(&t); 
printf("Time and Date: %s\n", \ 
asctime(local)); 

return 0; 
} 



函数名: drawpoly 
功 能: 画多边形 
用 法: void far drawpoly(int numpoints, int far *polypoints); 
程序例: 

#include <graphics.h> 
#include <stdlib.h> 
#include <stdio.h> 
#include <conio.h> 

int main(void) 
{ 
/* request auto detection */ 
int gdriver = DETECT, gmode, errorcode; 
int maxx, maxy; 

/* our polygon array */ 
int poly[10]; 

/* 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(); 
/* terminate with an error code */ 
exit(1); 
} 

maxx = getmaxx(); 
maxy = getmaxy(); 

poly[0] = 20; /* 1st vertext */ 
poly[1] = maxy / 2; 

poly[2] = maxx - 20; /* 2nd */ 
poly[3] = 20; 

poly[4] = maxx - 50; /* 3rd */ 
poly[5] = maxy - 20; 

poly[6] = maxx / 2; /* 4th */ 
poly[7] = maxy / 2; 
/* 
drawpoly doesn't automatically close 
the polygon, so we close it. 
*/ 
poly[8] = poly[0]; 
poly[9] = poly[1]; 

/* draw the polygon */ 
drawpoly(5, poly); 

/* clean up */ 
getch(); 
closegraph(); 
return 0; 
} 



函数名: dup 
功 能: 复制一个文件句柄 
用 法: int dup(int handle); 
程序例: 

#include <string.h> 
#include <stdio.h> 
#include <conio.h> 
#include <io.h> 

void flush(FILE *stream); 

int main(void) 
{ 
FILE *fp; 
char msg[] = "This is a test"; 

/* create a file */ 
fp = fopen("DUMMY.FIL", "w"); 

/* write some data to the file */ 
fwrite(msg, strlen(msg), 1, fp); 

clrscr(); 
printf("Press any key to flush \ 
DUMMY.FIL:"); 
getch(); 

/* flush the data to DUMMY.FIL without 
closing it */ 
flush(fp); 

printf("\nFile was flushed, Press any \ 
key to quit:"); 
getch(); 
return 0; 
} 

void flush(FILE *stream) 
{ 
int duphandle; 

/* flush TC's internal buffer */ 
fflush(stream); 

/* make a duplicate file handle */ 
duphandle = dup(fileno(stream)); 

/* close the duplicate handle to flush the 
DOS buffer */ 
close(duphandle); 
} 



函数名: dup2 
功 能: 复制文件句柄 
用 法: int dup2(int oldhandle, int newhandle); 
程序例: 

#include <sys\stat.h> 
#include <string.h> 
#include <fcntl.h> 
#include <io.h> 

int main(void) 
{ 
#define STDOUT 1 

int nul, oldstdout; 
char msg[] = "This is a test"; 

/* create a file */ 
nul = open("DUMMY.FIL", O_CREAT | O_RDWR, 
S_IREAD | S_IWRITE); 

/* create a duplicate handle for standard 
output */ 
oldstdout = dup(STDOUT); 
/* 
redirect standard output to DUMMY.FIL 
by duplicating the file handle onto the 
file handle for standard output. 
*/ 
dup2(nul, STDOUT); 

/* close the handle for DUMMY.FIL */ 
close(nul); 

/* will be redirected into DUMMY.FIL */ 
write(STDOUT, msg, strlen(msg)); 

/* restore original standard output 
handle */ 
dup2(oldstdout, STDOUT); 

/* close duplicate handle for STDOUT */ 
close(oldstdout); 

return 0; 
}  

--------------------------------------------------------------------------------

 
 
C语言库函数(E类字母) 
AiY.CN 收集整理 (2001-07-27 12:00:00) 
函数名: ecvt 
功 能: 把一个浮点数转换为字符串 
用 法: char ecvt(double value, int ndigit, int *decpt, int *sign); 
程序例: 

#include <stdlib.h> 
#include <stdio.h> 
#include <conio.h> 

int main(void) 
{ 
char *string; 
double value; 
int dec, sign; 
int ndig = 10; 

clrscr(); 
value = 9.876; 
string = ecvt(value, ndig, &dec, &sign); 
printf("string = %s dec = %d \ 
sign = %d\n", string, dec, sign); 

value = -123.45; 
ndig= 15; 
string = ecvt(value,ndig,&dec,&sign); 
printf("string = %s dec = %d sign = %d\n", 
string, dec, sign); 


value = 0.6789e5; /* scientific 
notation */ 
ndig = 5; 
string = ecvt(value,ndig,&dec,&sign); 
printf("string = %s dec = %d\ 
sign = %d\n", string, dec, sign); 

return 0; 
} 



函数名: ellipse 
功 能: 画一椭圆 
用 法: void far ellipse(int x, int y, int stangle, int endangle, 
int xradius, int yradius); 
程序例: 

#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; 
int stangle = 0, endangle = 360; 
int xradius = 100, yradius = 50; 

/* initialize graphics, 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 */ 
} 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -