c语言作业皇帝的许诺,C语言函数大全(s开头) (1)/继
函數(shù)名: setdta
功 能: 設(shè)置磁盤傳輸區(qū)地址
用 法: void setdta(char far *dta);
程序例:
#include
#include
#include
#include
int main(void)
{
char line[80], far *save_dta;
char buffer[256] = "SETDTA test!";
struct fcb blk;
int result;
printf("Enter a file name to create:");
gets(line);
parsfnm(line, &blk, 1);
printf("%d %s\n", blk.fcb_drive, blk.fcb_name);
if (bdosptr(0x16, &blk, 0) == -1)
{
perror("Error creating file");
exit(1);
}
save_dta = getdta();
setdta(buffer);
blk.fcb_recsize = 256;
blk.fcb_random = 0L;
result = randbwr(&blk, 1);
printf("result = %d\n", result);
if (!result)
printf("Write OK\n");
else
{
perror("Disk error");
exit(1);
}
if (bdosptr(0x10, &blk, 0) == -1)
{
perror("Error closing file");
exit(1);
}
setdta(save_dta);
return 0;
}
函數(shù)名: setfillpattern
功 能: 選擇用戶定義的填充模式
用 法: void far setfillpattern(char far *upattern, int color);
程序例:
#include
#include
#include
#include
int main(void)
{
int gdriver = DETECT, gmode, errorcode;
int maxx, maxy;
char pattern[8] = {0x00, 0x70, 0x20, 0x27, 0x24, 0x24, 0x07,
0x00};
initgraph(&gdriver, &gmode,
"");
errorcode = graphresult();
if (errorcode != grOk)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
maxx = getmaxx();
maxy = getmaxy();
setcolor(getmaxcolor());
setfillpattern(pattern, getmaxcolor());
bar(0, 0, maxx, maxy);
getch();
closegraph();
return 0;
}
函數(shù)名: setfillstyle
功 能: 設(shè)置填充模式和顏色
用 法: void far setfillstyle(int pattern, int color);
程序例:
#include
#include
#include
#include
#include
char *fname[] = { "EMPTY_FILL",
"SOLID_FILL",
"LINE_FILL",
"LTSLASH_FILL",
"SLASH_FILL",
"BKSLASH_FILL",
"LTBKSLASH_FILL",
"HATCH_FILL",
"XHATCH_FILL",
"INTERLEAVE_FILL",
"WIDE_DOT_FILL",
"CLOSE_DOT_FILL",
"USER_FILL"
};
int main(void)
{
int gdriver = DETECT, gmode, errorcode;
int style, midx, midy;
char stylestr[40];
initgraph(&gdriver, &gmode,
"");
errorcode = graphresult();
if (errorcode != grOk)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
midx = getmaxx() / 2;
midy = getmaxy() / 2;
for (style = EMPTY_FILL; style < USER_FILL;
style++)
{
setfillstyle(style, getmaxcolor());
strcpy(stylestr, fname[style]);
bar3d(0, 0, midx-10, midy, 0, 0);
outtextxy(midx, midy, stylestr);
getch();
cleardevice();
}
getch();
closegraph();
return 0;
}
函數(shù)名: setftime
功 能: 設(shè)置文件日期和時間
用 法: int setftime(int handle, struct ftime *ftimep);
程序例:
#include
#include
#include
#include
int main(void)
{
struct ftime filet;
FILE *fp;
if ((fp = fopen("TEST.$$$", "w")) == NULL)
{
perror("Error:");
exit(1);
}
fprintf(fp, "testing...\n");
filet.ft_tsec = 1;
filet.ft_min = 1;
filet.ft_hour = 1;
filet.ft_day = 1;
filet.ft_month = 1;
filet.ft_year = 21;
system("dir TEST.$$$");
setftime(fileno(fp), &filet);
fclose(fp);
system("dir TEST.$$$");
unlink("TEST.$$$");
return 0;
}
函數(shù)名: setgraphbufsize
功 能: 改變內(nèi)部圖形緩沖區(qū)的大小
用 法: unsigned far setgraphbufsize(unsigned bufsize);
程序例:
#include
#include
#include
#include
#define BUFSIZE 1000
int main(void)
{
int gdriver = DETECT, gmode, errorcode;
int x, y, oldsize;
char msg[80];
oldsize = setgraphbufsize(BUFSIZE);
initgraph(&gdriver, &gmode,
"");
errorcode = graphresult();
if (errorcode != grOk)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
x = getmaxx() / 2;
y = getmaxy() / 2;
sprintf(msg, "Graphics buffer size: %d", BUFSIZE);
settextjustify(CENTER_TEXT, CENTER_TEXT);
outtextxy(x, y, msg);
sprintf(msg, "Old graphics buffer size: %d", oldsize);
outtextxy(x, y+textheight("W"), msg);
getch();
closegraph();
return 0;
}
函數(shù)名: setgraphmode
功 能: 將系統(tǒng)設(shè)置成圖形模式且清屏
用 法: void far setgraphmode(int mode);
程序例:
#include
#include
#include #include
int main(void)
{
int gdriver = DETECT, gmode, errorcode;
int x, y;
initgraph(&gdriver, &gmode,
"");
errorcode = graphresult();
if (errorcode != grOk)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
x = getmaxx() / 2;
y = getmaxy() / 2;
settextjustify(CENTER_TEXT, CENTER_TEXT);
outtextxy(x, y, "Press any key to exit graphics:");
getch();
restorecrtmode();
printf("We're now in text mode.\n");
printf("Press any key to return to graphics mode:");
getch();
setgraphmode(getgraphmode());
settextjustify(CENTER_TEXT, CENTER_TEXT);
outtextxy(x, y, "We're back in graphics mode.");
outtextxy(x, y+textheight("W"), "Press any key to halt:");
getch();
closegraph();
return 0;
}
函數(shù)名: setjmp
功 能: 非局部轉(zhuǎn)移
用 法: int setjmp(jmp_buf env);
程序例:
#include
#include
#include
void subroutine(void);
jmp_buf jumper;
int main(void)
{
int value;
value = setjmp(jumper);
if (value != 0)
{
printf("Longjmp with value %d\n", value);
exit(value);
}
printf("About to call subroutine ... \n");
subroutine();
return 0;
}
void subroutine(void)
{
longjmp(jumper,1);
}
函數(shù)名: setlinestyle
功 能: 設(shè)置當(dāng)前畫線寬度和類型
用 法: void far setlinestyle(int linestype, unsigned upattern);
程序例:
#include
#include
#include
#include
#include
char *lname[] = {
"SOLID_LINE",
"DOTTED_LINE",
"CENTER_LINE",
"DASHED_LINE",
"USERBIT_LINE"
};
int main(void)
{
int gdriver = DETECT, gmode, errorcode;
int style, midx, midy, userpat;
char stylestr[40];
initgraph(&gdriver, &gmode,
"");
errorcode = graphresult();
if (errorcode != grOk)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
midx = getmaxx() / 2;
midy = getmaxy() / 2;
userpat = 1;
for (style=SOLID_LINE; style<=USERBIT_LINE;
style++)
{
setlinestyle(style, userpat, 1);
strcpy(stylestr, lname[style]);
line(0, 0, midx-10, midy);
rectangle(0, 0, getmaxx(), getmaxy());
outtextxy(midx, midy, stylestr);
getch();
cleardevice();
}
closegraph();
return 0;
}
函數(shù)名: setmem
功 能: 存值到存儲區(qū)
用 法: void setmem(void *addr, int len, char value);
程序例:
#include
#include
#include
int main(void)
{
char *dest;
dest = calloc(21, sizeof(char));
setmem(dest, 20, 'c');
printf("%s\n", dest);
return 0;
}
函數(shù)名: setmode
功 能: 設(shè)置打開文件方式
用 法: int setmode(int handle, unsigned mode);
程序例:
#include
#include
#include
int main(void)
{
int result;
result = setmode(fileno(stdprn), O_TEXT);
if (result == -1)
perror("Mode not available\n");
else
printf("Mode successfully switched\n");
return 0;
}
函數(shù)名: setpalette
功 能: 改變調(diào)色板的顏色
用 法: void far setpalette(int index, int actural_color);
程序例:
#include
#include
#include
#include
int main(void)
{
int gdriver = DETECT, gmode, errorcode;
int color, maxcolor, ht;
int y = 10;
char msg[80];
initgraph(&gdriver, &gmode,
"");
errorcode = graphresult();
if (errorcode != grOk)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
maxcolor = getmaxcolor();
ht = 2 * textheight("W");
for (color=1; color<=maxcolor; color++)
{
setcolor(color);
sprintf(msg, "Color: %d", color);
outtextxy(1, y, msg);
y += ht;
}
getch();
for (color=1; color<=maxcolor; color++)
{
setpalette(color, BLACK);
getch();
}
closegraph();
return 0;
}
函數(shù)名: setrgbpalette
功 能: 定義IBM8514圖形卡的顏色
用 法: void far setrgbpalette(int colornum, int red, int green, int
blue);
程序例:
#include
#include
#include
#include
int main(void)
{
int gdriver = VGA, gmode = VGAHI, errorcode;
struct palettetype pal;
int i, ht, y, xmax;
initgraph(&gdriver, &gmode,
"");
errorcode = graphresult();
if (errorcode != grOk)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
getpalette(&pal);
for (i=0; i
setrgbpalette(pal.colors[i], i*4, i*4, i*4);
ht = getmaxy() / 16;
xmax = getmaxx();
y = 0;
for (i=0; i
{
setfillstyle(SOLID_FILL, i);
bar(0, y, xmax, y+ht);
y += ht;
}
getch();
closegraph();
return 0;
}
函數(shù)名: settextjustify
功 能: 為圖形函數(shù)設(shè)置文本的對齊方式
用 法: void far settextjustify(int horiz, int vert);
程序例:
#include
#include
#include
#include
void xat(int x, int y);
char *hjust[] = { "LEFT_TEXT",
"CENTER_TEXT",
"RIGHT_TEXT"
};
char *vjust[] = { "LEFT_TEXT",
"CENTER_TEXT",
"RIGHT_TEXT"
};
int main(void)
{
int gdriver = DETECT, gmode, errorcode;
int midx, midy, hj, vj;
char msg[80];
initgraph(&gdriver, &gmode,
"");
errorcode = graphresult();
if (errorcode != grOk)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
midx = getmaxx() / 2;
midy = getmaxy() / 2;
for (hj=LEFT_TEXT; hj<=RIGHT_TEXT; hj++)
for (vj=LEFT_TEXT; vj<=RIGHT_TEXT; vj++)
{
cleardevice();
settextjustify(hj, vj);
sprintf(msg, "%s %s", hjust[hj], vjust[vj]);
xat(midx, midy);
outtextxy(midx, midy, msg);
getch();
}
closegraph();
return 0;
}
void xat(int x, int y)
{
line(x-4, y, x+4, y);
line(x, y-4, x, y+4);
}
函數(shù)名: settextstyle
功 能: 為圖形輸出設(shè)置當(dāng)前的文本屬性
用 法: void far settextstyle (int font, int direction, char
size);
程序例:
#include
#include
#include
#include
char *fname[] = { "DEFAULT font",
"TRIPLEX font",
"SMALL font",
"SANS SERIF font",
"GOTHIC font"
};
int main(void)
{
int gdriver = DETECT, gmode, errorcode;
int style, midx, midy;
int size = 1;
initgraph(&gdriver, &gmode,
"");
errorcode = graphresult();
if (errorcode != grOk)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
midx = getmaxx() / 2;
midy = getmaxy() / 2;
settextjustify(CENTER_TEXT, CENTER_TEXT);
for (style=DEFAULT_FONT; style<=GOTHIC_FONT;
style++)
{
cleardevice();
if (style == TRIPLEX_FONT)
size = 4;
settextstyle(style, HORIZ_DIR, size);
outtextxy(midx, midy, fname[style]);
getch();
}
closegraph();
return 0;
}
函數(shù)名: settextstyle
功 能: 為圖形輸出設(shè)置當(dāng)前的文本屬性
用 法: void far settextstyle (int font, int direction, char
size);
程序例:
#include
#include
#include
#include
char *fname[] = { "DEFAULT font",
"TRIPLEX font",
"SMALL font",
"SANS SERIF font",
"GOTHIC font"
};
int main(void)
{
int gdriver = DETECT, gmode, errorcode;
int style, midx, midy;
int size = 1;
initgraph(&gdriver, &gmode,
"");
errorcode = graphresult();
if (errorcode != grOk)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
midx = getmaxx() / 2;
midy = getmaxy() / 2;
settextjustify(CENTER_TEXT, CENTER_TEXT);
for (style=DEFAULT_FONT; style<=GOTHIC_FONT;
style++)
{
cleardevice();
if (style == TRIPLEX_FONT)
size = 4;
settextstyle(style, HORIZ_DIR, size);
outtextxy(midx, midy, fname[style]);
getch();
}
closegraph();
return 0;
}
函數(shù)名: settime
功 能: 設(shè)置系統(tǒng)時間
用 法: void settime(struct time *timep);
程序例:
#include
#include
int main(void)
{
struct time t;
gettime(&t);
printf("The current minute is: %d\n", t.ti_min);
printf("The current hour is: %d\n", t.ti_hour);
printf("The current hundredth of a second is: %d\n",
t.ti_hund);
printf("The current second is: %d\n", t.ti_sec);
t.ti_min++;
settime(&t);
return 0;
}
函數(shù)名: setusercharsize
功 能: 為矢量字體改變字符寬度和高度
用 法: void far setusercharsize(int multx, int dirx, int multy, int
diry);
程序例:
#include
#include
#include
#include
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);
}
settextstyle(TRIPLEX_FONT, HORIZ_DIR, 4);
moveto(0, getmaxy() / 2);
outtext("Norm ");
setusercharsize(1, 3, 1, 1);
outtext("Short ");
setusercharsize(3, 1, 1, 1);
outtext("Wide");
getch();
closegraph();
return 0;
}
函數(shù)名: setvbuf
功 能: 把緩沖區(qū)與流相關(guān)
用 法: int setvbuf(FILE *stream, char *buf, int type, unsigned
size);
程序例:
#include
int main(void)
{
FILE *input, *output;
char bufr[512];
input = fopen("file.in", "r+b");
output = fopen("file.out", "w");
if (setvbuf(input, bufr, _IOFBF, 512) != 0)
printf("failed to set up buffer for input file\n");
else
printf("buffer set up for input file\n");
if (setvbuf(output, NULL, _IOLBF, 132) != 0)
printf("failed to set up buffer for output file\n");
else
printf("buffer set up for output file\n");
fclose(input);
fclose(output);
return 0;
}
函數(shù)名: setvect
功 能: 設(shè)置中斷矢量入口
用 法: void setvect(int intr_num, void interrupt(*isr)());
程序例:
#include
#include
#include
#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;
}
函數(shù)名: setverify
功 能: 設(shè)置驗(yàn)證狀態(tài)
用 法: void setverify(int value);
程序例:
#include
#include
#include
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;
}
函數(shù)名: setviewport
功 能: 為圖形輸出設(shè)置當(dāng)前視口
用 法: void far setviewport(int left, int top, int right,
int bottom, int clipflag);
程序例:
#include
#include
#include
#include
#define CLIP_ON 1
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);
}
setcolor(getmaxcolor());
outtextxy(0, 0, "*
viewport");
setviewport(50, 50, getmaxx()-50, getmaxy()-50, CLIP_ON);
outtextxy(0, 0, "*
viewport");
getch();
closegraph();
return 0;
}
總結(jié)
以上是生活随笔為你收集整理的c语言作业皇帝的许诺,C语言函数大全(s开头) (1)/继的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux红外键盘映射表,linux下修
- 下一篇: 只读字符串的c语言命令,C语言只读空间