📄 fs.htm
字号:
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=gb_2312-80">
<meta name="Author" content="wdg">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
<title>网上学堂 --> C语言编程宝典之一 -->函数名: s</title>
</head>
<body>
<div align="center"><center>
<table border="1" cellpadding="4" width="640"
bordercolordark="#FFFFFF" bordercolorlight="#FFFFFF">
<tr>
<td bgcolor="#FFE6B0" bordercolor="#8080FF" class="p9"><font
color="#BB0000">导航条:--></font> <a
href="../../index.html">网上学堂</a> --> <a
href="../tcindex.htm"><font face="宋体">C</font>语言编程宝典之一</a>
-->函数名: s</td>
</tr>
<tr>
<td bordercolor="#8080FF" class="p9">函数名: sbrk <br>
功 能: 改变数据段空间位置 <br>
用 法: char *sbrk(int incr); <br>
程序例: <p>#include <stdio.h> <br>
#include <alloc.h> </p>
<p>int main(void) <br>
{ <br>
printf("Changing allocation with
sbrk()\n"); <br>
printf("Before sbrk() call: %lu bytes
free\n", <br>
(unsigned long) coreleft()); <br>
sbrk(1000); <br>
printf(" After sbrk() call: %lu bytes
free\n", <br>
(unsigned long) coreleft()); <br>
return 0; <br>
} <br>
<br>
</p>
<p>函数名: scanf <br>
功 能: 执行格式化输入 <br>
用 法: int scanf(char *format[,argument,...]); <br>
程序例: </p>
<p>#include <stdio.h> <br>
#include <conio.h> </p>
<p>int main(void) <br>
{ <br>
char label[20]; <br>
char name[20]; <br>
int entries = 0; <br>
int loop, age; <br>
double salary; </p>
<p> struct Entry_struct <br>
{ <br>
char name[20]; <br>
int age; <br>
float salary; <br>
} entry[20]; </p>
<p>/* Input a label as a string of characters restricting
to 20 characters */ <br>
printf("\n\nPlease enter a label for
the chart: "); <br>
scanf("%20s", label); <br>
fflush(stdin); /* flush the input
stream in case of bad input */ </p>
<p>/* Input number of entries as an integer */ <br>
printf("How many entries will there be?
(less than 20) "); <br>
scanf("%d", &entries); <br>
fflush(stdin); /* flush the
input stream in case of bad input */ </p>
<p>/* input a name restricting input to only letters
upper or lower case */ <br>
for (loop=0;loop<entries;++loop) <br>
{ <br>
printf("Entry
%d\n", loop); <br>
printf(" Name
: "); <br>
scanf("%[A-Za-z]", entry[loop].name); <br>
fflush(stdin); /*
flush the input stream in case of bad input */ </p>
<p>/* input an age as an integer */ <br>
printf(" Age
: "); <br>
scanf("%d",
&entry[loop].age); <br>
fflush(stdin); /*
flush the input stream in case of bad input */ </p>
<p>/* input a salary as a float */ <br>
printf(" Salary
: "); <br>
scanf("%f",
&entry[loop].salary); <br>
fflush(stdin); /* flush
the input stream in case of bad input */ <br>
} </p>
<p>/* Input a name, age and salary as a string, integer,
and double */ <br>
printf("\nPlease enter your name, age
and salary\n"); <br>
scanf("%20s %d %lf", name,
&age, &salary); <br>
</p>
<p>/* Print out the data that was input */ <br>
printf("\n\nTable %s\n",label); <br>
printf("Compiled by %s age %d
$%15.2lf\n", name, age, salary); <br>
printf("-----------------------------------------------------\n");
<br>
for (loop=0;loop<entries;++loop) <br>
printf("%4d | %-20s |
%5d | %15.2lf\n", <br>
loop +
1, <br>
entry[loop].name, <br>
entry[loop].age, <br>
entry[loop].salary); <br>
printf("-----------------------------------------------------\n");
<br>
return 0; <br>
} <br>
<br>
</p>
<p>函数名: searchpath <br>
功 能: 搜索DOS路径 <br>
用 法: char *searchpath(char *filename); <br>
程序例: </p>
<p>#include <stdio.h> <br>
#include <dir.h> </p>
<p>int main(void) <br>
{ <br>
char *p; </p>
<p> /* Looks for TLINK and returns a pointer <br>
to the path */ <br>
p = searchpath("TLINK.EXE"); <br>
printf("Search for TLINK.EXE :
%s\n", p); </p>
<p> /* Looks for non-existent file */ <br>
p = searchpath("NOTEXIST.FIL"); <br>
printf("Search for NOTEXIST.FIL :
%s\n", p); </p>
<p> return 0; <br>
} <br>
<br>
</p>
<p>函数名: sector <br>
功 能: 画并填充椭圆扇区 <br>
用 法: void far sector(int x, int y, int stangle,
int endangle); <br>
程序例: </p>
<p>#include <graphics.h> <br>
#include <stdlib.h> <br>
#include <stdio.h> <br>
#include <conio.h> </p>
<p>int main(void) <br>
{ <br>
/* request auto detection */ <br>
int gdriver = DETECT, gmode, errorcode; <br>
int midx, midy, i; <br>
int stangle = 45, endangle = 135; <br>
int xrad = 100, yrad = 50; </p>
<p> /* initialize graphics and local
variables */ <br>
initgraph(&gdriver, &gmode,
""); </p>
<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 error code */ <br>
} </p>
<p> midx = getmaxx() / 2; <br>
midy = getmaxy() / 2; </p>
<p> /* loop through the fill patterns */ <br>
for (i=EMPTY_FILL; i<USER_FILL; i++) <br>
{ <br>
/* set the fill style */ <br>
setfillstyle(i,
getmaxcolor()); </p>
<p> /* draw the sector
slice */ <br>
sector(midx, midy,
stangle, endangle, xrad, yrad); </p>
<p> getch(); <br>
} </p>
<p> /* clean up */ <br>
closegraph(); <br>
return 0; <br>
} <br>
</p>
<p>函数名: segread <br>
功 能: 读段寄存器值 <br>
用 法: void segread(struct SREGS *segtbl); <br>
程序例: </p>
<p>#include <stdio.h> <br>
#include <dos.h> </p>
<p>int main(void) <br>
{ <br>
struct SREGS segs; </p>
<p> segread(&segs); <br>
printf("Current segment register
settings\n\n"); <br>
printf("CS: %X DS:
%X\n", segs.cs, segs.ds); <br>
printf("ES: %X SS:
%X\n", segs.es, segs.ss); </p>
<p> return 0; <br>
} <br>
<br>
</p>
<p>函数名: setactivepage <br>
功 能: 设置图形输出活动页 <br>
用 法: void far setactivepage(int pagenum); <br>
程序例: </p>
<p>#include <graphics.h> <br>
#include <stdlib.h> <br>
#include <stdio.h> <br>
#include <conio.h> </p>
<p>int main(void) <br>
{ <br>
/* select a driver and mode that supports */
<br>
/* multiple pages.
*/ <br>
int gdriver = EGA, gmode = EGAHI, errorcode;
<br>
int x, y, ht; </p>
<p> /* initialize graphics and local
variables */ <br>
initgraph(&gdriver, &gmode,
""); </p>
<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 error code */ <br>
} </p>
<p> x = getmaxx() / 2; <br>
y = getmaxy() / 2; <br>
ht = textheight("W"); </p>
<p> /* select the off screen page for
drawing */ <br>
setactivepage(1); </p>
<p> /* draw a line on page #1 */ <br>
line(0, 0, getmaxx(), getmaxy()); </p>
<p> /* output a message on page #1 */ <br>
settextjustify(CENTER_TEXT, CENTER_TEXT); <br>
outtextxy(x, y, "This is page
#1:"); <br>
outtextxy(x, y+ht, "Press any key to
halt:"); </p>
<p> /* select drawing to page #0 */ <br>
setactivepage(0); </p>
<p> /* output a message on page #0 */ <br>
outtextxy(x, y, "This is page
#0."); <br>
outtextxy(x, y+ht, "Press any key to
view page #1:"); <br>
getch(); </p>
<p> /* select page #1 as the visible page */ <br>
setvisualpage(1); </p>
<p> /* clean up */ <br>
getch(); <br>
closegraph(); <br>
return 0; <br>
} <br>
<br>
</p>
<p>函数名: setallpallette <br>
功 能:
按指定方式改变所有的调色板颜色 <br>
用 法: void far setallpallette(struct palette,
far *pallette); <br>
程序例: </p>
<p>#include <graphics.h> <br>
#include <stdlib.h> <br>
#include <stdio.h> <br>
#include <conio.h> </p>
<p>int main(void) <br>
{ <br>
/* request auto detection */ <br>
int gdriver = DETECT, gmode, errorcode; <br>
struct palettetype pal; <br>
int color, maxcolor, ht; <br>
int y = 10; <br>
char msg[80]; </p>
<p> /* initialize graphics and local
variables */ <br>
initgraph(&gdriver, &gmode,
""); </p>
<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 error code */ <br>
} </p>
<p> maxcolor = getmaxcolor(); <br>
ht = 2 * textheight("W"); </p>
<p> /* grab a copy of the palette */ <br>
getpalette(&pal); </p>
<p> /* display the default palette colors */ <br>
for (color=1; color<=maxcolor; color++) <br>
{ <br>
setcolor(color); <br>
sprintf(msg, "Color:
%d", color); <br>
outtextxy(1, y, msg); <br>
y += ht; <br>
} </p>
<p> /* wait for a key */ <br>
getch(); </p>
<p> /* black out the colors one by one */ <br>
for (color=1; color<=maxcolor; color++) <br>
{ <br>
setpalette(color, BLACK); <br>
getch(); <br>
} </p>
<p> /* restore the palette colors */ <br>
setallpalette(&pal); </p>
<p> /* clean up */ <br>
getch(); <br>
closegraph(); <br>
return 0; <br>
} <br>
<br>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -