c语⾔建⽴坐标的代码,C语⾔getx()⽤法及代码⽰例头⽂件graphics.h包含getx()函数,该函数返回当前位置的X坐标。句法:
int getx();
例:
说明:最初,当前位置的X坐标为0。使⽤moveto()函数移动坐标时,X坐标更改为80。
下⾯是getx()函数的实现:
// C Implementation for getx()
#include
#include
// driver code
int main()
{
// gm is Graphics mode which is
// a computer display mode that
// generates image using pixels.
// DETECT is a macro defined in
// "graphics.h" header file
int gd = DETECT, gm;
char arr[100];
// initgraph initializes the
// graphics system by loading a
/
/ graphics driver from disk
initgraph(&gd, &gm, "");
// sprintf stands for “String print”.
// Instead of printing on console, it
// store output on char buffer which
// are specified in sprintf
sprintf(arr, "Current position of x = %d",
getx());
// outtext function displays text at
// current position.
outtext(arr);
/
/ moveto function
moveto(80, 50);
sprintf(arr, "Current position of x = %d", getx());
// outtext function displays text at
// current position.
outtext(arr);
getch();
// closegraph function closes the
// graphics mode and deallocates
// all memory allocated by
// graphics system .
closegraph();c语言char的用法
return 0;
}
输出:
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论