📄 fs.htm
字号:
<BR> getch();<BR> closegraph();<BR> return 0;<BR>}<BR> <BR> <P>函数名: setbkcolor<BR>功 能: 用调色板设置当前背景颜色<BR>用 法: void far setbkcolor(int color);<BR>程序例:<P>#include <graphics.h><BR>#include <stdlib.h><BR>#include <stdio.h><BR>#include <conio.h><P>int main(void)<BR>{<BR> /* select a driver and mode that supports */<BR> /* multiple background colors. */<BR> int gdriver = EGA, gmode = EGAHI, errorcode;<BR> int bkcol, maxcolor, x, y;<BR> char msg[80];<P> /* initialize graphics and local variables */<BR> initgraph(&gdriver, &gmode, "");<P> /* read result of initialization */<BR> errorcode = graphresult();<BR> if (errorcode != grOk) /* an error occurred */<BR> {<BR> printf("Graphics error: %s\n", grapherrormsg(errorcode));<BR> printf("Press any key to halt:");<BR> getch();<BR> exit(1); /* terminate with an errorcode */<BR> }<P> /* maximum color index supported */<BR> maxcolor = getmaxcolor();<P> /* for centering text messages */<BR> settextjustify(CENTER_TEXT, CENTER_TEXT);<BR> x = getmaxx() / 2;<BR> y = getmaxy() / 2;<P> /* loop through the available colors */<BR> for (bkcol=0; bkcol<=maxcolor; bkcol++)<BR> {<BR> /* clear the screen */<BR> cleardevice();<P> /* select a new background color */<BR> setbkcolor(bkcol);<P> /* output a messsage */<BR> if (bkcol == WHITE)<BR> setcolor(EGA_BLUE);<BR> sprintf(msg, "Background color: %d",bkcol);<BR> outtextxy(x, y, msg);<BR> getch();<BR> }<P> /* clean up */<BR> closegraph();<BR> return 0;<BR>}<BR> <BR> <P>函数名: setblock<BR>功 能: 修改先前已分配的DOS存储段大小<BR>用 法: int setblock(int seg, int newsize);<BR>程序例:<P>#include <dos.h><BR>#include <alloc.h><BR>#include <stdio.h><BR>#include <stdlib.h><P>int main(void)<BR>{<BR> unsigned int size, segp;<BR> int stat;<P> size = 64; /* (64 x 16) = 1024 bytes */<BR> stat = allocmem(size, &segp);<BR> if (stat == -1)<BR> printf("Allocated memory at segment:%X\n", segp);<BR> else<BR> {<BR> printf("Failed: maximum number of paragraphsavailable is %d\n",<BR> stat);<BR> exit(1);<BR> }<P> stat = setblock(segp, size * 2);<BR> if (stat == -1)<BR> printf("Expanded memory block at segment:%X\n", segp);<BR> else<BR> printf("Failed: maximum number of paragraphsavailable is %d\n",<BR> stat);<P> freemem(segp);<P> return 0;<BR>}<BR> <BR> <P>函数名: setbuf<BR>功 能: 把缓冲区与流相联<BR>用 法: void setbuf(FILE *steam, char *buf);<BR>程序例:<P>#include <stdio.h><P>/* BUFSIZ is defined in stdio.h */<BR>char outbuf[BUFSIZ];<P>int main(void)<BR>{<BR> /* attach a buffer to the standard output stream */<BR> setbuf(stdout, outbuf);<P> /* put some characters into the buffer */<BR> puts("This is a test of buffered output.\n\n");<BR> puts("This output will go into outbuf\n");<BR> puts("and won't appear until the buffer\n");<BR> puts("fills up or we flush the stream.\n");<P> /* flush the output buffer */<BR> fflush(stdout);<P> return 0;<BR>}<BR> <BR> <P>函数名: setcbrk<BR>功 能: 设置Control-break<BR>用 法: int setcbrk(int value);<BR>程序例:<P>#include <dos.h><BR>#include <conio.h><BR>#include <stdio.h><P>int main(void)<BR>{<BR> int break_flag;<P> printf("Enter 0 to turn control break off\n");<BR> printf("Enter 1 to turn control break on\n");<P> break_flag = getch() - 0;<P> setcbrk(break_flag);<P> if (getcbrk())<BR> printf("Cntrl-brk flag is on\n");<BR> else<BR> printf("Cntrl-brk flag is off\n");<BR> return 0;<BR>}<BR> <BR> <BR> <P>函数名: setcolor<BR>功 能: 设置当前画线颜色<BR>用 法: void far setcolor(int color);<BR>程序例:<P>#include <graphics.h><BR>#include <stdlib.h><BR>#include <stdio.h><BR>#include <conio.h><P>int main(void)<BR>{<BR> /* select a driver and mode that supports */<BR> /* multiple drawing colors. */<BR> int gdriver = EGA, gmode = EGAHI, errorcode;<BR> int color, maxcolor, x, y;<BR> char msg[80];<P> /* initialize graphics and local variables */<BR> initgraph(&gdriver, &gmode, "");<P> /* read result of initialization */<BR> errorcode = graphresult();<BR> if (errorcode != grOk) /* an error occurred */<BR> {<BR> printf("Graphics error: %s\n", grapherrormsg(errorcode));<BR> printf("Press any key to halt:");<BR> getch();<BR> exit(1); /* terminate with an errorcode */<BR> }<P> /* maximum color index supported */<BR> maxcolor = getmaxcolor();<P> /* for centering text messages */<BR> settextjustify(CENTER_TEXT, CENTER_TEXT);<BR> x = getmaxx() / 2;<BR> y = getmaxy() / 2;<P> /* loop through the available colors */<BR> for (color=1; color<=maxcolor; color++)<BR> {<BR> /* clear the screen */<BR> cleardevice();<P> /* select a new background color */<BR> setcolor(color);<P> /* output a messsage */<BR> sprintf(msg, "Color: %d", color);<BR> outtextxy(x, y, msg);<BR> getch();<BR> }<P> /* clean up */<BR> closegraph();<BR> return 0;<BR>}<BR> <BR> <P>函数名: setdate<BR>功 能: 设置DOS日期<BR>用 法: void setdate(struct date *dateblk);<BR>程序例:<P>#include <stdio.h><BR>#include <process.h><BR>#include <dos.h><P>int main(void)<BR>{<BR> struct date reset;<BR> struct date save_date;<P> getdate(&save_date);<BR> printf("Original date:\n");<BR> system("date");<P> reset.da_year = 2001;<BR> reset.da_day = 1;<BR> reset.da_mon = 1;<BR> setdate(&reset);<P> printf("Date after setting:\n");<BR> system("date");<P> setdate(&save_date);<BR> printf("Back to original date:\n");<BR> system("date");<P> return 0;<BR>}<BR> <BR> <P>函数名: setdisk<BR>功 能: 设置当前磁盘驱动器<BR>用 法: int setdisk(int drive);<BR>程序例:<P>#include <stdio.h><BR>#include <dir.h><P>int main(void)<BR>{<BR> int save, disk, disks;<P> /* save original drive */<BR> save = getdisk();<P> /* print number of logic drives */<BR> disks = setdisk(save);<BR> printf("%d logical drives on the system\n\n", disks);<P> /* print the drive letters available */<BR> printf("Available drives:\n");<BR> for (disk = 0;disk < 26;++disk)<BR> {<BR> setdisk(disk);<BR> if (disk == getdisk())<BR> printf("%c: driveis available\n", disk + 'a');<BR> }<BR> setdisk(save);<P> return 0;<BR>}<BR> <BR> <P>函数名: setdta<BR>功 能: 设置磁盘传输区地址<BR>用 法: void setdta(char far *dta);<BR>程序例:<P>#include <process.h><BR>#include <string.h><BR>#include <stdio.h><BR>#include <dos.h><P>int main(void)<BR>{<BR> char line[80], far *save_dta;<BR> char buffer[256] = "SETDTA test!";<BR> struct fcb blk;<BR> int result;<P> /* get new file name from user */<BR> printf("Enter a file name to create:");<BR> gets(line);<P> /* parse the new file name to the dta */<BR> parsfnm(line, &blk, 1);<BR> printf("%d %s\n", blk.fcb_drive, blk.fcb_name);<P> /* request DOS services to create file */<BR> if (bdosptr(0x16, &blk, 0) == -1)<BR> {<BR> perror("Error creating file");<BR> exit(1);<BR> }<P> /* save old dta and set new dta */<BR> save_dta = getdta();<BR> setdta(buffer);<P> /* write new records */<BR> blk.fcb_recsize = 256;<BR> blk.fcb_random = 0L;<BR> result = randbwr(&blk, 1);<BR> printf("result = %d\n", result);<P> if (!result)<BR> printf("Write OK\n");<BR> else<BR> {<BR> perror("Disk error");<BR> exit(1);<BR> }<P> /* request DOS services to close the file */<BR> if (bdosptr(0x10, &blk, 0) == -1)<BR> {<BR> perror("Error closing file");<BR> exit(1);<BR> }<P> /* reset the old dta */<BR> setdta(save_dta);<BR> return 0;<BR>}<BR> <BR> <P>函数名: setfillpattern<BR>功 能: 选择用户定义的填充模式<BR>用 法: void far setfillpattern(char far *upattern, int color);<BR>程序例:<P>#include <graphics.h><BR>#include <stdlib.h><BR>#include <stdio.h><BR>#include <conio.h><P>int main(void)<BR>{<BR> /* request auto detection */<BR> int gdriver = DETECT, gmode, errorcode;<BR> int maxx, maxy;<P> /* a user defined fill pattern */<BR> char pattern[8] = {0x00, 0x70, 0x20, 0x27, 0x24, 0x24,0x07, 0x00};<P> /* initialize graphics and local variables */<BR> initgraph(&gdriver, &gmode, "");<P> /* read result of initialization */<BR> errorcode = graphresult();<BR> if (errorcode != grOk) /* an error occurred */<BR> {<BR> printf("Graphics error: %s\n", grapherrormsg(errorcode));<BR> printf("Press any key to halt:");<BR> getch();<BR> exit(1); /* terminate with an errorcode */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -