c语言中moveto和lineto函数什么意思,怎么用,什么时候用,说详细点,刚学图形

Python021

c语言中moveto和lineto函数什么意思,怎么用,什么时候用,说详细点,刚学图形,第1张

moveto(50,50)是将画笔移动到参数指定的坐标(50,50)

lineto(150,50)是从画笔的当前位置绘制一条直线到参数给的坐标(150,50)

所以这两句的结果就是画了一条直线,从50,50开始到150,50结束

这两个函数不难的

分类函数,所在函数库为ctype.h

int isalpha(int ch)若ch是字母('A'-'Z','a'-'z')返回非0值,否则返回0

int isalnum(int ch)若ch是字母('A'-'Z','a'-'z')或数字('0'-'9')

返回非0值,否则返回0

int isascii(int ch)若ch是字符(ASCII码中的0-127)返回非0值,否则返回0

int iscntrl(int ch)若ch是作废字符(0x7F)或普通控制字符(0x00-0x1F)

返回非0值,否则返回0

int isdigit(int ch)若ch是数字('0'-'9')返回非0值,否则返回0

int isgraph(int ch)若ch是可打印字符(不含空格)(0x21-0x7E)返回非0值,否则返回0

int islower(int ch)若ch是小写字母('a'-'z')返回非0值,否则返回0

int isprint(int ch)若ch是可打印字符(含空格)(0x20-0x7E)返回非0值,否则返回0

int ispunct(int ch)若ch是标点字符(0x00-0x1F)返回非0值,否则返回0

int isspace(int ch)若ch是空格(' '),水平制表符('\t'),回车符('\r'),

走纸换行('\f'),垂直制表符('\v'),换行符('\n')

返回非0值,否则返回0

int isupper(int ch)若ch是大写字母('A'-'Z')返回非0值,否则返回0

int isxdigit(int ch) 若ch是16进制数('0'-'9','A'-'F','a'-'f')返回非0值,

否则返回0

int tolower(int ch)若ch是大写字母('A'-'Z')返回相应的小写字母('a'-'z')

int toupper(int ch)若ch是小写字母('a'-'z')返回相应的大写字母('A'-'Z')

数学函数,所在函数库为math.h、stdlib.h、string.h、float.h

intabs(int i) 返回整型参数i的绝对值

doublecabs(struct complex znum)返回复数znum的绝对值

doublefabs(double x) 返回双精度参数x的绝对值

long labs(long n) 返回长整型参数n的绝对值

double exp(double x) 返回指数函数ex的值

double frexp(double value,int *eptr) 返回value=x*2n中x的值,n存贮在eptr中

double ldexp(double value,int exp) 返回value*2exp的值

double log(double x) 返回logex的值

double log10(double x) 返回log10x的值

double pow(double x,double y) 返回xy的值

double pow10(int p) 返回10p的值

doublesqrt(double x) 返回+√x的值

doubleacos(double x) 返回x的反余弦cos-1(x)值,x为弧度

doubleasin(double x) 返回x的反正弦sin-1(x)值,x为弧度

doubleatan(double x) 返回x的反正切tan-1(x)值,x为弧度

double atan2(double y,double x) 返回y/x的反正切tan-1(x)值,y的x为弧度

double cos(double x) 返回x的余弦cos(x)值,x为弧度

double sin(double x) 返回x的正弦sin(x)值,x为弧度

double tan(double x) 返回x的正切tan(x)值,x为弧度

doublecosh(double x) 返回x的双曲余弦cosh(x)值,x为弧度

doublesinh(double x) 返回x的双曲正弦sinh(x)值,x为弧度

doubletanh(double x) 返回x的双曲正切tanh(x)值,x为弧度

double hypot(double x,double y) 返回直角三角形斜边的长度(z),

x和y为直角边的长度,z2=x2+y2

doubleceil(double x) 返回不小于x的最小整数

double floor(double x) 返回不大于x的最大整数

void srand(unsigned seed) 初始化随机数发生器

int rand() 产生一个随机数并返回这个数

doublepoly(double x,int n,double c[])从参数产生一个多项式

doublemodf(double value,double *iptr)将双精度数value分解成尾数和阶

doublefmod(double x,double y) 返回x/y的余数

double frexp(double value,int *eptr) 将双精度数value分成尾数和阶

doubleatof(char *nptr) 将字符串nptr转换成浮点数并返回这个浮点数

doubleatoi(char *nptr) 将字符串nptr转换成整数并返回这个整数

doubleatol(char *nptr) 将字符串nptr转换成长整数并返回这个整数

char *ecvt(double value,int ndigit,int *decpt,int *sign)

将浮点数value转换成字符串并返回该字符串

char *fcvt(double value,int ndigit,int *decpt,int *sign)

将浮点数value转换成字符串并返回该字符串

char *gcvt(double value,int ndigit,char *buf)

将数value转换成字符串并存于buf中,并返回buf的指针

char*ultoa(unsigned long value,char *string,int radix)

将无符号整型数value转换成字符串并返回该字符串,radix为转换时所用基数

char *ltoa(long value,char *string,int radix)

将长整型数value转换成字符串并返回该字符串,radix为转换时所用基数

char *itoa(int value,char *string,int radix)

将整数value转换成字符串存入string,radix为转换时所用基数

double atof(char *nptr) 将字符串nptr转换成双精度数,并返回这个数,错误返回0

int atoi(char *nptr) 将字符串nptr转换成整型数,并返回这个数,错误返回0

long atol(char *nptr) 将字符串nptr转换成长整型数,并返回这个数,错误返回0

double strtod(char *str,char **endptr)将字符串str转换成双精度数,并返回这个数,

long strtol(char *str,char **endptr,int base)将字符串str转换成长整型数,

并返回这个数,

intmatherr(struct exception *e)

用户修改数学错误返回信息函数(没有必要使用)

double _matherr(_mexcep why,char *fun,double *arg1p,

double *arg2p,double retval)

用户修改数学错误返回信息函数(没有必要使用)

unsigned int _clear87() 清除浮点状态字并返回原来的浮点状态

void _fpreset() 重新初使化浮点数学程序包

unsigned int _status87()返回浮点状态字

int chdir(char *path) 使指定的目录path(如:"C:\\WPS")变成当前的工作目录,成

功返回0

int findfirst(char *pathname,struct ffblk *ffblk,int attrib)查找指定的文件,成功

返回0

pathname为指定的目录名和文件名,如"C:\\WPS\\TXT"

ffblk为指定的保存文件信息的一个结构,定义如下:

┏━━━━━━━━━━━━━━━━━━━━┓

┃struct ffblk┃

┃{ ┃

┃ char ff_reserved[21]/*DOS保留字*/┃

┃ char ff_attrib/*文件属性*/┃

┃ intff_ftime /*文件时间*/ ┃

┃ intff_fdate /*文件日期*/ ┃

┃ long ff_fsize /*文件长度*/┃

┃ char ff_name[13] /*文件名*/ ┃

┃} ┃

┗━━━━━━━━━━━━━━━━━━━━━┛

attrib为文件属性,由以下字符代表

┏━━━━━━━━━┳━━━━━━━━━┓

┃FA_RDONLY 只读文件┃FA_LABEL卷标号 ┃

┃FA_HIDDEN 隐藏文件┃FA_DIREC目录┃

┃FA_SYSTEM 系统文件┃FA_ARCH 档案┃

┗━━━━━━━━━┻━━━━━━━━━┛

例:

struct ffblk ff

findfirst("*.wps",&ff,FA_RDONLY)

int findnext(struct ffblk *ffblk)取匹配finddirst的文件,成功返回0

voidfumerge(char *path,char *drive,char *dir,char *name,char *ext)

此函数通过盘符drive(C:、A:等),路径dir(\TC、\BC\LIB等),

文件名name(TC、WPS等),扩展名ext(.EXE、.COM等)组成一个文件名

存与path中.

int fnsplit(char *path,char *drive,char *dir,char *name,char *ext)

此函数将文件名path分解成盘符drive(C:、A:等),路径dir(\TC、\BC\LIB等),

文件名name(TC、WPS等),扩展名ext(.EXE、.COM等),并分别存入相应的变量中.

int getcurdir(int drive,char *direc) 此函数返回指定驱动器的当前工作目录名称

drive 指定的驱动器(0=当前,1=A,2=B,3=C等)

direc 保存指定驱动器当前工作路径的变量成功返回0

char *getcwd(char *buf,iint n) 此函数取当前工作目录并存入buf中,直到n个字

节长为为止.错误返回NULL

int getdisk() 取当前正在使用的驱动器,返回一个整数(0=A,1=B,2=C等)

int setdisk(int drive) 设置要使用的驱动器drive(0=A,1=B,2=C等),

返回可使用驱动器总数

int mkdir(char *pathname)建立一个新的目录pathname,成功返回0

int rmdir(char *pathname)删除一个目录pathname,成功返回0

char *mktemp(char *template) 构造一个当前目录上没有的文件名并存于template中

char *searchpath(char *pathname) 利用MSDOS找出文件filename所在路径,

,此函数使用DOS的PATH变量,未找到文件返回NULL

进程函数,所在函数库为stdlib.h、process.h

voidabort() 此函数通过调用具有出口代码3的_exit写一个终止信息于stderr,

并异常终止程序。无返回值

int exec…装入和运行其它程序

int execl(char *pathname,char *arg0,char *arg1,…,char *argn,NULL)

int execle( char *pathname,char *arg0,char *arg1,…,

char *argn,NULL,char *envp[])

int execlp( char *pathname,char *arg0,char *arg1,…,NULL)

int execlpe(char *pathname,char *arg0,char *arg1,…,NULL,char *envp[])

int execv(char *pathname,char *argv[])

int execve( char *pathname,char *argv[],char *envp[])

int execvp( char *pathname,char *argv[])

int execvpe(char *pathname,char *argv[],char *envp[])

exec函数族装入并运行程序pathname,并将参数

arg0(arg1,arg2,argv[],envp[])传递给子程序,出错返回-1

在exec函数族中,后缀l、v、p、e添加到exec后,

所指定的函数将具有某种操作能力

有后缀p时,函数可以利用DOS的PATH变量查找子程序文件。

l时,函数中被传递的参数个数固定。

v时,函数中被传递的参数个数不固定。

e时,函数传递指定参数envp,允许改变子进程的环境,

无后缀e时,子进程使用当前程序的环境。

void_exit(int status)终止当前程序,但不清理现场

voidexit(int status) 终止当前程序,关闭所有文件,写缓冲区的输出(等待输出),

并调用任何寄存器的"出口函数",无返回值

int spawn…运行子程序

int spawnl(int mode,char *pathname,char *arg0,char *arg1,…,

char *argn,NULL)

int spawnle( int mode,char *pathname,char *arg0,char *arg1,…,

char *argn,NULL,char *envp[])

int spawnlp( int mode,char *pathname,char *arg0,char *arg1,…,

char *argn,NULL)

int spawnlpe(int mode,char *pathname,char *arg0,char *arg1,…,

char *argn,NULL,char *envp[])

int spawnv(int mode,char *pathname,char *argv[])

int spawnve( int mode,char *pathname,char *argv[],char *envp[])

int spawnvp( int mode,char *pathname,char *argv[])

int spawnvpe(int mode,char *pathname,char *argv[],char *envp[])

spawn函数族在mode模式下运行子程序pathname,并将参数

arg0(arg1,arg2,argv[],envp[])传递给子程序.出错返回-1

mode为运行模式

mode为 P_WAIT 表示在子程序运行完后返回本程序

P_NOWAIT 表示在子程序运行时同时运行本程序(不可用)

P_OVERLAY表示在本程序退出后运行子程序

在spawn函数族中,后缀l、v、p、e添加到spawn后,

所指定的函数将具有某种操作能力

有后缀 p时, 函数利用DOS的PATH查找子程序文件

l时, 函数传递的参数个数固定.

v时, 函数传递的参数个数不固定.

e时, 指定参数envp可以传递给子程序,允许改变子程序运行环境.

当无后缀e时,子程序使用本程序的环境.

int system(char *command) 将MSDOS命令command传递给DOS执行

转换子程序,函数库为math.h、stdlib.h、ctype.h、float.h

char *ecvt(double value,int ndigit,int *decpt,int *sign)

将浮点数value转换成字符串并返回该字符串

char *fcvt(double value,int ndigit,int *decpt,int *sign)

将浮点数value转换成字符串并返回该字符串

char *gcvt(double value,int ndigit,char *buf)

将数value转换成字符串并存于buf中,并返回buf的指针

char*ultoa(unsigned long value,char *string,int radix)

将无符号整型数value转换成字符串并返回该字符串,radix为转换时所用基数

char *ltoa(long value,char *string,int radix)

将长整型数value转换成字符串并返回该字符串,radix为转换时所用基数

char *itoa(int value,char *string,int radix)

将整数value转换成字符串存入string,radix为转换时所用基数

double atof(char *nptr) 将字符串nptr转换成双精度数,并返回这个数,错误返回0

int atoi(char *nptr) 将字符串nptr转换成整型数,并返回这个数,错误返回0

long atol(char *nptr) 将字符串nptr转换成长整型数,并返回这个数,错误返回0

double strtod(char *str,char **endptr)将字符串str转换成双精度数,并返回这个数,

long strtol(char *str,char **endptr,int base)将字符串str转换成长整型数,

并返回这个数,

int toascii(int c) 返回c相应的ASCII

int tolower(int ch)若ch是大写字母('A'-'Z')返回相应的小写字母('a'-'z')

int _tolower(int ch)返回ch相应的小写字母('a'-'z')

int toupper(int ch)若ch是小写字母('a'-'z')返回相应的大写字母('A'-'Z')

int _toupper(int ch)返回ch相应的大写字母('A'-'Z')

诊断函数,所在函数库为assert.h、math.h

void assert(int test) 一个扩展成if语句那样的宏,如果test测试失败,

就显示一个信息并异常终止程序,无返回值

void perror(char *string) 本函数将显示最近一次的错误信息,格式如下:

字符串string:错误信息

char *strerror(char *str) 本函数返回最近一次的错误信息,格式如下:

字符串str:错误信息

int matherr(struct exception *e)

用户修改数学错误返回信息函数(没有必要使用)

double _matherr(_mexcep why,char *fun,double *arg1p,

double *arg2p,double retval)

用户修改数学错误返回信息函数(没有必要使用)