c语言库函数大全s-u.docx.pdf

上传人:tbuqq 文档编号:5615882 上传时间:2020-07-02 格式:PDF 页数:11 大小:216.10KB
返回 下载 相关 举报
c语言库函数大全s-u.docx.pdf_第1页
第1页 / 共11页
c语言库函数大全s-u.docx.pdf_第2页
第2页 / 共11页
c语言库函数大全s-u.docx.pdf_第3页
第3页 / 共11页
c语言库函数大全s-u.docx.pdf_第4页
第4页 / 共11页
c语言库函数大全s-u.docx.pdf_第5页
第5页 / 共11页
点击查看更多>>
资源描述

《c语言库函数大全s-u.docx.pdf》由会员分享,可在线阅读,更多相关《c语言库函数大全s-u.docx.pdf(11页珍藏版)》请在三一文库上搜索。

1、C语言库函数大全S-U 2009-11-27 10:28 函数名 :sctdta 功能:设置磁盘传输区地址 用法:void setdta(char far *dta); 程序例: #include process.h #inelude ftinclude #include int main(void) char line80, far *save_dta; char buffer256 = “SETDTA test! struct feb blk; int result; /* get new file name from user */ printf(Enter a file name to

2、 create: z, ); gets (line); /* parse the new file name to the dta */ parsfnm(line, printf (“%d %sn“, blk? fcb_drivc, blk? feb_name); /* request DOS services to create file */ if (bdosptr(0x16, /* save old dta and set new dta */ save dta = getdtaO ; setdta (buffer); /* write new records */ blk ? fcb_

3、rccsizc = 256; blk.fcb_random = 0L; result = randbwr ( printf ( z/ resul t = %dn,resul t); if (Iresult) printf(“Write 0Kn); else perror( Z/ Disk error“); exit(1); /* request DOS services to close the file */ if (bdosptr(0x10, /* reset the old dta */ setdta (save_dta); return 0; 函数名:setfillpattern 功

4、能:选择用户定义的填充模式 用 法:void far setfillpattern(char far upattern, int color); 程序例: Sincludegraphics. h include #inelude ttinclude int main(void) /* request auto detection */ int gdriver 二DETECT, gmode, errorcode; int maxx, maxy; /* a user defined fill pattern */ char pattern8 = 0x00, 0x70, 0x20, 0x27, 0x

5、24, 0x24, 0x07, 0x00; /* initialize graphics and local variables */ initgraph ( if (errorcode != grOk) A an error occurred */ printf(“Graphics error: %sn,grapherrormsg(errorcode); printf( z,Press any key to halt:“); maxx = getmaxx (); maxy 二getmaxy (); setcolor(getmaxcolor (); /* select a user defin

6、ed fill pattern */ setfilipattern(pattern, getmaxcolor(); /* fill the screen with the pattern */ bar (0, 0, maxx, maxy); /* clean up */ getchO ; closegraph(); return 0; 函数名:setpalette 功 能:改变调色板的颜色 用 法:void far setpalette(int index, int actural_color); 程序例: “ #inelude itinclude #inelude ftinclude int

7、 main (void) /* request auto detection */ int gdriver 二DETECT, gmodc, errorcode; int color, maxcolor, ht; int y = 10; char msg80; /* initialize graphics and local variables */ initgraph( /* read result of initialization */ errorcode 二graphresult(); if (errorcode != grOk) /* an error occurred */ prin

8、tf(Graphics error: %sn“, grapherrormsg(errorcode); printf ( z, Press any key to halt: ,z); maxcolor = getmaxcolor(); ht 二2 * textheight ( W) ; /* display the default colors */ for (color=l; color include #inelude Sinclude int main (void) char 1ine80, far *save_dta; char buffer256 = “SETDTA test! str

9、uct feb blk; int result; /* get new file name from user */ printf(Enter a file name to create: z,); gets (line); /* parse the new file name to the dta */ parsfnm(line, printf (“%d %sn“, blk? fcb_drivc, blk? fcb_name); /* request DOS services to create file */ if (bdosptr(0x16, /* save old dta and se

10、t new dta */ save dta = getdtaO ; setdta (buffer); /* write new records */ blk ? fcb_rccsizc = 256; blk.fcb_random = 0L; result = randbwr ( printf ( z/ resul t = %dn,resul t); if (Iresult) printf(“Write 0Kn); else perror( Z/ Disk error“); exit (1); /* request DOS services to close the file */ if (bd

11、osptr(0x10, exit (1); /* reset the old dta */ setdta (save_dta); return 0; :setf11lpattern 能:选择用户定义的填充模式 法:void far sctfillpeittcrn(char far *upattcrn, int color); ttinclude #include #inelude Binclude int main (void) /* request auto detection */ int gdriver = DETECT, gmode, errorcode; int maxx, maxy

12、; /* a user defined fill pattern */ char pattern8 = 0x00, 0x70, 0x20, 0x27, 0x24, 0x24, 0x07, 0x00; /* initialize graphics and local variables */ initgraph( /* read result of initialization */ errorcode 二graphresult(); if (errorcode != grOk) /* an error occurred */ printf(Graphics error: %sn,grapher

13、rormsg(errorcode); printf ( /z Press any key to halt: /z ); getch(); exit(1); /* terminate with an error code */ maxx = getmaxx(); maxy = getmaxy (); setcolor(getmaxcolor (); /* select a user defined fil1 pattern */ setfi1lpattcrn(pattern, getmaxcolor(); /* fill the screen with the pattern */ bar (0

14、, 0, maxx, maxy); /* clean up */ getch(); closcgraphO ; return 0; 函数名:ultoa 功 能:转换一个无符号长整型数为字符串 用 法:char *ultoa(unsigned long value, char string, int radix); 程序例: 功 用 程 ttinclude ftinclude int main( void ) unsigned long lnumber 二3123456789L; char string25; ultoa(lnumbcr, string,10); printf( z,string

15、 = %s unsigned long 二%lun /z , string, lnumber); return 0; 函数名:ungetc 功 能:把一个字符退回到输入流中 用 法:int ungetc (char c, FTLE * stream); 程序例: #inelude #include int main( void ) int i=0; char ch; puts (Input an integer followed by a char:) ; /* read chars until non digit or EOF */ while(ch = getchar() != EOF /

16、* convert ASCII into int value */ /* if non dig it char was read, push it back into input buffer */ if (ch != EOF) ungetc (ch, stdin); printf ( z, i = %d, next char in buffer = %ci, getchar(); return 0; 函数名:ungetch 功能:把一个字符退回到键盘缓冲区中 用法:int ungetch(int c); 程序例: ttinclude Winclude include int main( vo

17、id ) int i=0; char ch; puts ( Z, Tnput an integer fol lowed by a char: /z ); /* read chars until non digit or EOF */ while (ch = gctcheO) != EOF /* convert ASCII into int value */ /* if non digit char was read, push it back into input buffer */ if (ch != EOF) ungetch (ch); printf ( ,z nni = %d, nex

18、t char in buffer 二cn,i, get ch (); return 0; 函数名 :unixtodos 功 能:把口期和时间转换成DOS格式 用 法:void unixtodos (long utime, struct date dateptr, struct time *timeptr); 程序例: #inelude Sinclude 厂1 ? A Winclude int main(void) FILE *fp = fopen ( ,zjunk ? jnk“, ; int status; fprintf(fp, junk); status 二access ( /z junk

19、. jnk,0); if (status = 0) printf(“File existsn); else printf(“File doesnt existn); fclose (fp); uni ink(junk. jnk); status = access ( z, junk. jn0); if (status = 0) printf(“File existsn); else printf(“File doesnt exist; return 0; 函数名:unlock 功能:解除文件共享锁 用 法:int uni ock( int hem die, long offset, long

20、len gth); 程序例: Sinclude #inelude #includeprocess. h #inelude #include int main(void) int handle, status; long length; handle = sopen (c:autoexec. bat“, 0_RD0NLY, SH_DENYN0, S_IREAD); if (handle 0) printf(“sopcn failcdrT); exit (1); length 二filelength(handle); status 二lock (handle, 0L,length/2); if (status = 0) printf ( z, lock succeededn); el se printf(“lock failedn ,/ ); status = unlock (handle, OL, length/2); if (status = 0) printf(“unlock succeededn); el se printf ( z, unlock failedn ,z); close(handle); return 0;

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 其他


经营许可证编号:宁ICP备18001539号-1