C语言库函数(G类字母)4

2008-04-09 03:59:32来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

C语言库函数(G类字母)4


函数名: getpass
功 能: 读一个口令
用 法: char *getpass(char *prompt);
程序例:

#include <conio.h>

int main(void)
{
char *password;

password = getpass("Input a password:");
cprintf("The password is: %s\r\n",
password);
return 0;
}




函数名: getpixel
功 能: 取得指定像素的颜色
用 法: int far getpixel(int x, int y);
程序例:

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

#define PIXEL_COUNT 1000
#define DELAY_TIME 100 /* in milliseconds */

int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int i, x, y, color, maxx, maxy,
maxcolor, seed;

/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");

/* read result of initialization */
errorcode = graphresult();
/* an error occurred */
if (errorcode != grOk)
{
printf("Graphics error: %s\n",
grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
/* terminate with an error code */
exit(1);
}

maxx = getmaxx() 1;
maxy = getmaxy() 1;
maxcolor = getmaxcolor() 1;

while (!kbhit())
{
/* seed the random number generator */
seed = random(32767);
srand(seed);
for (i=0; i<PIXEL_COUNT; i )
{
x = random(maxx);
y = random(maxy);
color = random(maxcolor);
putpixel(x, y, color);
}

delay(DELAY_TIME);
srand(seed);
for (i=0; i<PIXEL_COUNT; i )
{
x = random(maxx);
y = random(maxy);
color = random(maxcolor);
if (color == getpixel匇? ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;h;(;);;; ;e;t;p;s;p;(;););;; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;e;s;e;t; ;t;o; ;s;e;g;m;e;n;t; ;o;f; ;t;h;e; ;P;S;P; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;i;n;e; ;i;s; ;l;o;c;a;t;e;d; ;a;t; ;o;f;f;s;e;t; ;0;x;8;1; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;t; ;o;f; ;P;S;P; ; ; ; ; ; ; ; ;


函数名: gets
功 能: 从流中取一字符串
用 法: char *gets(char *string);
程序例:

#include <stdio.h>

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

printf("Input a string:");
gets(string);
printf("The string input was: %s\n",
string);
return 0;
}



函数名: gettext
功 能: 将文本方式屏幕上的文本拷贝到存储区
用 法: int gettext(int left, int top, int right, int bottom, void *destin);
程序例:

#include <conio.h>

char buffer[4096];

int main(void)
{
int i;
clrscr();
for (i = 0; i <= 20; i )
cprintf("Line #%d\r\n", i);
gettext(1, 1, 80, 25, buffer);
gotoxy(1, 25);
cprintf("Press any key to clear screen...");
getch();
clrscr();
gotoxy(1, 25);
cprintf("Press any key to restore screen...");
getch();
puttext(1, 1, 80, 25, buffer);
gotoxy(1, 25);
cprintf("Press any key to quit...");
getch();
return 0;
}



函数名: gettextinfo
功 能: 取得文本模式的显示信息
用 法: void gettextinfo(struct text_info *inforec);
程序例:

#include <conio.h>

int main(void)
{
struct text_info ti;
gettextinfo(&ti);
cprintf("window left -\r\n",ti.winleft);
cprintf("window top -\r\n",ti.wintop);
cprintf("window right -\r\n",ti.winright);
cprintf("window bottom -\r\n",ti.winbottom);
cprintf("attribute -\r\n",ti.attribute);
cprintf("normal attribute -\r\n",ti.normattr);
cprintf("current mode -\r\n",ti.currmode);
cprintf("screen height -\r\n",ti.screenheight);
cprintf("screen width -\r\n",ti.screenwidth);
cprintf("current x -\r\n",ti.curx);
cprintf("current y -\r\n",ti.cury);
return 0;
}



函数名: gettextsettings
功 能: 返回有关当前图形文本字体的信息
用 法: void far gettextsettings(struct textsettingstype far *textinfo);
程序例:

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

/* the names of the fonts supported */
char *font[] = { "DEFAULT_FONT",
"TRIPLEX_FONT",
"SMALL_FONT",
"SANS_SERIF_FONT",
"GOTHIC_FONT"
};

/* the names of the text directions supported */
char *dir[] = { "HORIZ_DIR", "VERT_DIR" };

/* horizontal text justifications supported */
char *hjust[] = { "LEFT_TEXT", "CENTER_TEXT", "RIGHT_TEXT" };

/* vertical text justifications supported */
char *vjust[] = { "BOTTOM_TEXT", "CENTER_TEXT", "TOP_TEXT" };

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:C语言库函数(F类字母)

下一篇:C语言库函数(B类字母)