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

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

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

c4468b3f4df77e96b0a416fa2a870fba.png

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

函数名: getpass

功 能: 读一个口令

用 法: char *getpass(char *prompt);

程序例:

#include

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

#include

#include

#include

#include

#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

{

x = random(maxx);

y = random(maxy);

color = random(maxcolor);

putpixel(x, y, color);

}

delay(DELAY_TIME);

srand(seed);

for (i=0; 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

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

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

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

#include

#include

#include

/* 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

特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

相关文章

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值