当前位置:首页 » 编程语言 » c语言自相关函数

c语言自相关函数

发布时间: 2022-06-18 09:04:39

linuxc语言环境变量操作的几个相关函数

这几个函数的原型在<stdio.h>中定义

/* Return the value of envariable NAME, or NULL if it doesn't exist. */
extern char *getenv (__const char *__name) __THROW __nonnull ((1)) __wur;

/* The SVID says this is in <stdio.h>, but this seems a better place. */
/* Put STRING, which is of the form "NAME=VALUE", in the environment.
If there is no `=', remove NAME from the environment. */
extern int putenv (char *__string) __THROW __nonnull ((1));

/* Set NAME to VALUE in the environment.
If REPLACE is nonzero, overwrite an existing value. */
extern int setenv (__const char *__name, __const char *__value, int __replace)
__THROW __nonnull ((2));

/* Remove the variable NAME from the environment. */
extern int unsetenv (__const char *__name) __THROW __nonnull ((1));

㈡ c语言里面怎么判断一个数是不是整数有没有相关的函数

float
x;
int
y;
scnaf("%f",&x);
y=x;
if
(
y==x
)
printf("%d是整数。\n",(int)x);
else
printf("%f不是整数。\n",x);
当然也可以用简单的条件判断:if
(
(int)x==x
)
...

㈢ c语言的相关运算

第一题因为1>0 而值为10
第二题,答案为4无争议。
你说的问题是编译器的问题,例如 x++*x--+--x 的问题,类似vc6.0编译器会先将x++或x--的x值都取出来然后再做运算
可能和正常的理解不太一样,但编译器就是这样编译的,你可以多用几个例子试一试,就知道了 。

㈣ 有一个数组,有1024个点,在C语言中实现这个数组的自相关函数R()

不会c语言啊

㈤ 有没有什么书籍或者资料可以详细讲讲c语言图形库graphics等相关函数用法

C/C++主要功能是对文件的操作,但不包括图形操作,你看过哪本C/C++的书教你画窗体,控件啥的? 一般来说,C/C++里的图形处理都需要第三方开发的库,如OpenGL.或者一些编译器像Dev-C里自带的有绘图函数,如果你用的是Linux环境,可以考虑使用KDE,QT等在C语言下开发图形处理.QT的书有卖的,我们学校图书馆就有. 关于图形函数库的使用手册你可以到官网去查,很完整,不过几乎全是英语,就看你水平如何了.书店里这方面的书实在是少.

㈥ 求教C语言 指针 自定义函数相关问题 请教出错原因

  1. 把main中的void average();改成void average(float *,int);。

  2. 把main中的void search();改成void search(float (*)[4],int);。

  3. 把main中的void average(*score,12);改成average(*score,12);。

  4. 把main中的voidsearch(score,2);改成search(score,2);。

若有问题再说。以上仅是语法错误……

㈦ C语言中的include< dir.h>中的相关函数和作用

chdir()改变当前目录的函数
原形:int chdir(const char *path)
功能:把由path指定的目录改为当前目录。path参数中可以指定驱动器号,如“a:\\ddd”, 但只是改变该驱动器上的当前目录,对当前活动驱动器上的当前目录无影响。
返回值:0(成功);-1(失败)
头文件:dir.h
=======================================================================================
findfirst()函数和findnext()函数
调用方式:整形数=findfirst(文件名,&结构变量名,属性常数组合(如0x26));其中定义struct ffblk 结构变量名;
原形:int findfirst(path,buffer,attr)和int findnext(buffer)
char *path;//要检索的文件名
struct ffblk
{
char ff_reserved[21];
char ff_attrib;//被检索的文件属性
unsigned ff_ftime;//最后修改的时间
//(0-4位:秒数/2;5-10位:分数;11-15位:小时数)
unsigned ff_fdate;//最后修改的日期
//(0-4位:日;5-8位:月;9-15位:年减1980)
long ff_fsize;//文件大小
char ff_name[13];//组名
}*buffer;
int attr;//要检索的文件属性
功能:检索由path和attr指定的文件,把结果返回到buffer。findfirst返回关于第一个指定文件的信息,findnext继续检索。
返回值:0(检索成功),-1(没有找到指定的文件)
属性常数:
FA_NORMAL(0x00) 含意:Normal file, no attributes
FA_RDONLY(0x01) 含意:只读
FA_HIDDEN(0x02) 含意:隐含文件
FA_SYSTEM(0x04) 含意:系统文件
FA_LABEL(0x08) 含意:卷标
FA_DIREC(0x10) 含意:子目录
FA_ARCH(0x20) 含意:修改的文件Archive
头文件:dir.h(dos.h)
====================================================================================
fnmerge()建立文件路径函数
原形:void fnmerge(char *path,const char *drive,const char *dir, const char *name,const char *ext)
功能:合成drive:\dir\name.ext,放在path
头文件:dir.h

fnsplit()分解完整的路径名函数
原形:int fnsplit(char *path,const char *drive,const char *dir,const char *name,const char *ext)
功能:把文件名路径path分成4个部分存放。
其中drive中有冒号;dir中有开始和结尾的反斜杠;ext包括开始圆点
返回值:如果有扩展名,则 返回值&EXTENSION!=0
如果有文件名,则 返回值&FILENAME!=0
如果有目录名,则 返回值&DIRECTORY!=0
如果有驱动器号,则返回值&DIRVE!=0
头文件:dir.h
====================================================================================
getcurdir()读取指定驱动器的当前目录的函数
原形:int getcurdir(int drive,char directory)
drive=0(缺省);1(A驱动器);...
directory用来存放目录名,不包括驱动器名,不以反斜杠开始。
返回值:0(调用成功);1(出错)
头文件:dir.h

getcwd()读取当前目录的函数
原形:char *getcwd(char *buf,int buflen)
功能:读取当前目录的完整路径名(包括驱动器名),最长为buflen个字节,存放在buf中。如果buf为NULL,函数将分配一个buflen字节长的缓冲区,以后可将本函数的返回值作为free函数的参数来释放该缓冲区。
返回值:若buf非空,调用成功返回buf,出错返回NULL;若buf为NULL,返回指向已经分配的内存缓冲区地址。
头文件:dir.h

getdisk()读取当前磁盘驱动器号函数
原形:int getdisk(void)
功能:取得当前驱动器号(0=A;1=B;....)
头文件:dir.h
======================================================================================
mkdir()创建目录函数
原形:int mkdir(const char *path)
功能:按给定的路径建立一个新的目录
头文件:dir.h
返回值:0(成功);-1(失败)

mktemp()建立一个唯一的文件名的函数
原形:char *mktemp(char *template)
功能:使用一个唯一的文件名来替换字符串template,并返回template。
头文件:dir.h
======================================================================================
rmdir()删除目录函数
原形:int rmdir(const char *path)
注意:删除的目录不能是当前目录,不是根目录,是空目录
返回值:0(成功);-1(操作出错)
头文件:dir.h

searchpath()按dos路径查找一个文件的函数
原形:char *searchpath(const char *file)
用法:p=searchpath("文件名"); 先定义char *p;
功能:搜索dos路径(环境变量中的path=....)来定位由file给出的文件。
返回值:指向完整路径名字符串的指针。定位失败返回NULL。
头文件:dir.h

segread()读段寄存器函数
原形:void segread(struct SREGS *segp)
作用:把当前寄存器的值保存到SREGS型机构变量segp中。
segs.cs=代码段寄存器的值;
segs.ds=数据段寄存器的值;
segs.es=附加段寄存器的值;
segs.ss=堆栈段寄存器的值;

setdisk()设置当前驱动器的函数
原形:int setdisk(int drive)
功能:把由drive指定的驱动器修改成当前驱动器,返回可使用的驱动器数。
头文件:dir.h

settextstyle()显示字符的当前设置函数
功能:设置当前输出英文字符的字体、大小和方向。
调用方式:
void far settextstyle(int font,int direction,int charsize)
其中①参数font确定所选定的字体形状,
DEFAULT_FONT 或0 是8×8位图字体
TRIPLEX_FONT 或1 是三重矢量字体
SMALL_FONT 或2 是小号矢量字体
SANS_SERIF_FONT或3 是无衬线矢量字体
GOTHIC_FONT 或4 是哥特矢量字体
②参数rection字符的显示方向,
HORIZ_DIR 或0 是水平方向
VERT_DIR 或1 是垂直方向
③参数charsize表示字符放大的倍数,其值为0到10。

setvect()设置中断向量函数
setvect(int 中断号,void interrupt(*中断函数名))
功能:把中断服务程序的地址装入中断向量表中。
调用方法:setvect(中断号,中断函数名即地址);
(1)得预先定义要代替原函数的新函数
void interrupt 中断函数名(void)
{......}
(2)得先保留原中断函数地址
void interrupt (*保留函数名)(void);
保留函数名=getvect(中断号);
(3)事后得将原中断函数地址装回向量表中
setvect(中断号,保留函数名);

setviewport()建立视口的函数
原形: void far setviewport(int left,int top,int right,int bottom,int clip)
功能:用左上角坐标left,top和右下角坐标right,bottom建立一个视口,如果clip为1,则超出视口的输出自动被剪裁掉;如果clip为0,则不被剪裁。
例:setviewport(0,0,100,100,1)建立对角线为0,0和100,100的视口,并带有剪裁功能。
注:要清除当前视口,用函数clearnviewport()。

㈧ 如何用C语言直接定义自相关函数

#include<stdio.h>
floatdata[25]={1,2,3,4,5,6,7,8,9,10,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8};
floatr[15];
intN=10;
inti,m;
floatAutocorrelation(floatdata[],intN)
{for(m=0;m<5;m++){r[m]=0;}
for(m=0;m<N;m++)for(i=1;i<=N;i++)r[m]+=data[i]*data[i+m];
returnr[N-1];}
voidmain()
{for(m=0;m<5;m++)
{r[m]=Autocorrelation(data,N);
printf("%f ",r[m]);}
getch();
}

㈨ (c语言)文件相关函数的返回值

fgetc():成功时返回读入的字节数。错误或文件尾时返回EOF;
fputc():成功时返回写入的字节数。错误时返回EOF;
fgets():成功时返回字符串地址,错误或0读入时返回NULL;
fputs():成功时返回一个非负整数,错误时返回EOF
fprintf():成功时返回写入的字节数,错误时返回负数(negative value)
fscanf():返回正确读入项目(items)的个数,错误时返回EOF
fwrite():返回正确写入项目的个数,错误时返回0
fread():返回正确读入项目的个数,错误时返回0
fseek():成功返回0,错误返回-1。

㈩ C语言库函数的相关概念

函数名:abort
功 能:异常终止一个进程
函数与形参类型:
void abort(void);
程序例:
#include <stdio.h>
#include <stdlib.h> int main(void)
{
printf(Calling abort() );
abort();
return 0; /* This is never reached */
} 函数名:abs
功 能:计算整数num的值。返回整数num的绝对值
函数与参数类型:
int abs(num)
int num;
程序例:
#include <stdio.h>
#include <math.h> int main(void)
{
int number = -1234; printf(number: %d absolute value: %d , number, abs(number));
return 0;
} 函数名: absread, abswirte
功 能:绝对磁盘扇区读、写数据
函数与形参类型:
int absread(int drive, int nsects, int sectno, void *buffer);
int abswrite(int drive, int nsects, in tsectno, void *buffer);
程序例:
/* absread example */ #include <stdio.h>
#include <conio.h>
#include <process.h>
#include <dos.h> int main(void)
{
int i, strt, ch_out, sector;
char buf[512]; printf(Insert a diskette into drive A and press any key );
getch();
sector = 0;
if (absread(0, 1, sector, &buf) != 0)
{
perror(Disk problem);
exit(1);
}
printf(Read OK );
strt = 3;
for (i=0; i<80; i++)
{
ch_out = buf[strt+i];
putchar(ch_out);
}
printf( );
return(0);
} 函数名:access
功 能:确定文件的访问权限
函数与形参类型:
int access(const char *filename, int amode);
程序例:
#include <stdio.h>
#include <io.h> int file_exists(char *filename); int main(void)
{
printf(Does NOTEXIST.FIL exist: %s ,
file_exists(NOTEXISTS.FIL) ? YES : NO);
return 0;
} int file_exists(char *filename)
{
return (access(filename, 0) == 0);
} 函数名: acos
功 能:计算并返回arccos(x)值、要求-1<=X<=1
函数与形参类型:
double acos(x)
double x;
程序例:
#include <stdio.h>
#include <math.h> int main(void)
{
double result;
double x = 0.5; result = acos(x);
printf(The arc cosine of %lf is %lf , x, result);
return 0;
} 函数名:allocmem
功 能:分配DOS存储
函数与形参类型:
int allocmem(unsigned size, unsigned *seg);
程序例:
#include <dos.h>
#include <alloc.h>
#include <stdio.h> int main(void)
{
unsigned int size, segp;
int stat; size = 64; /* (64 x 16) = 1024 bytes */
stat = allocmem(size, &segp);
if (stat == -1)
printf(Allocated memory at segment: %x , segp);
else
printf(Failed: maximum number of paragraphs available is %u ,
stat); return 0;
} 函数名:arc
功 能:画一弧线
函数与形参类型:
void far arc(int x, int y, int stangle, int endangle, int radius);
程序例:
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int midx, midy;
int stangle = 45, endangle = 135;
int radius = 100; /* initialize graphics and local variables */
initgraph(&gdriver, &gmode, ); /* read result of initialization */
errorcode = graphresult(); /* an error occurred */
if (errorcode != grOk)
{
printf(Graphics error: %s , grapherrormsg(errorcode));
printf(Press any key to halt:);
getch(); exit(1); /* terminate with an error code */
} midx = getmaxx() / 2;
midy = getmaxy() / 2;
setcolor(getmaxcolor()); /* draw arc */
arc(midx, midy, stangle, endangle, radius); /* clean up */
getch();
closegraph();
return 0;
} 函数名: asctime
功 能:转换日期和时间为ASCII码
函数与形参类型:
char *asctime(const struct tm *tblock);
程序例:
#include <stdio.h>
#include <string.h>
#include <time.h> int main(void)
{
struct tm t;
char str[80]; /* sample loading of tm structure */ t. tm_sec = 1; /* Seconds */
t. tm_min = 30; /* Minutes */
t. tm_hour = 9; /* Hour */
t. tm_mday = 22; /* Day of the Month */
t. tm_mon = 11; /* Month */
t. tm_year = 56; /* Year - does not include century */
t. tm_wday = 4; /* Day of the week */
t. tm_yday = 0; /* Does not show in asctime */
t. tm_isdst = 0; /* Is Daylight SavTime; does not show in asctime */ /* converts structure to null terminated
string */ strcpy(str, asctime(&t));
printf(%s , str); return 0;
} 函数名::asin
功 能::计算并返回arcsin(x)值、要求-1<=X<=1
函数与形参类型:
double asin(x)
double x;
程序例:
#include <stdio.h>
#include <math.h> int main(void)
{
double result;
double x = 0.5; result = asin(x);
printf(The arc sin of %lf is %lf , x, result);
return(0);
} 函数名: assert
功 能:测试一个条件并可能使程序终止
函数与形参类型:
void assert(int test);
程序例:
#include <assert.h>
#include <stdio.h>
#include <stdlib.h> struct ITEM {
int key;
int value;
}; /* add item to list, make sure list is not null */
void additem(struct ITEM *itemptr) {
assert(itemptr != NULL);
/* add item to list */
} int main(void)
{
additem(NULL);
return 0;
} 函数名:atan
功 能:计算并返回arctan(x)的值
函数与形参类型:
double atan(double x);
程序例:
#include <stdio.h>
#include <math.h> int main(void)
{
double result;
double x = 0.5; result = atan(x);
printf(The arc tangent of %lf is %lf , x, result);
return(0);
} 函数名: atan2
功 能:计算并返回arctan(x/y)值
函数与形参类型:
double atan2(double y, double x);
程序例:
#include <stdio.h>
#include <math.h> int main(void)
{
double result;
double x = 90.0, y = 45.0; result = atan2(y, x);
printf(The arc tangent ratio of %lf is %lf , (y / x), result);
return 0;
} 函数名: atexit
功 能:注册终止函数
函数与形参类型:
int atexit(atexit_t func);
程序例:
#include <stdio.h>
#include <stdlib.h> void exit_fn1(void)
{
printf(Exit function #1 called );
} void exit_fn2(void)
{
printf(Exit function #2 called );
} int main(void)
{
/* post exit function #1 */
atexit(exit_fn1);
/* post exit function #2 */
atexit(exit_fn2);
return 0;
} 函数名: atof
功 能:把str指向的ASCⅡ字符串转换成一个double型整数返回双精度的结果
函数与形参类型:
double atof(str)
char*str;
程序例:
#include <stdlib.h>
#include <stdio.h> int main(void)
{
float f;
char *str = 12345.67; f = atof(str);
printf(string = %s float = %f , str, f);
return 0;
} 函数名:atoi
功 能:
把str指向的ASCⅡz字符串转换成一个整数。返回整数结果
函数与参数类型:
double atoi(str )
char *str;
程序例:
#include <stdlib.h>
#include <stdio.h> int main(void)
{
int n;
char *str = 12345.67; n = atoi(str);
printf(string = %s integer = %d , str, n);
return 0;
} 函数名:atol
功 能:
把字符串转换成长整型数 。返回长整数结果
函数与参数类型:
long atol(str )
char *str;
程序例:
#include <stdlib.h>
#include <stdio.h> int main(void)
{
long l;
char *str = 98765432; l = atol(lstr);
printf(string = %s integer = %ld , str, l);
return(0);
} 函数名:mkdir
功 能:建立一个目录
用 法:
int mkdir(char *pathname);
程序例:
#include <stdio.h>
#include <conio.h>
#include <process.h>
#include <dir.h>
int main(void)
{
int status;
clrscr();
status = mkdir(asdfjklm);
(!status) ? (printf(Directory created )) :
(printf(Unable to create directory ));
getch();
system(dir);
getch();
status = rmdir(asdfjklm);
(!status) ? (printf(Directory deleted )) :
(perror(Unable to delete directory));
return 0;
} 函数名: mktemp
功 能:建立唯一的文件名
用 法:
char *mktemp(char *template);
程序例:
#include <dir.h>
#include <stdio.h>
int main(void)
{
/* fname defines the template for the
temporary file. */
char *fname = TXXXXXX, *ptr;
ptr = mktemp(fname);
printf(%s ,ptr);
return 0;
} 函数名: MK_FP
功 能:设置一个远指针
用 法:
void far *MK_FP(unsigned seg, unsigned off);
程序例:
#include <dos.h>
#include <graphics.h>
int main(void)
{
int gd, gm, i;
unsigned int far *screen;
detectgraph(&gd, &gm);
if (gd == HERCMONO)
screen = MK_FP(0xB000, 0);
else
screen = MK_FP(0xB800, 0);
for (i=0; i<26; i++)
screen[i] = 0x0700 + ('a' + i);
return 0;
} 函数名: modf
功 能:把数分为整数和尾数
用 法:
double modf(double value, double *iptr);
程序例:
#include <math.h>
#include <stdio.h>
int main(void)
{
double fraction, integer;
double number = 100000.567;
fraction = modf(number, &integer);
printf(The whole and fractional parts of %lf are %lf and %lf ,
number, integer, fraction);
return 0;
} 函数名: movedata
功 能:拷贝字节
用 法:
void movedata(int segsrc, int offsrc, int segdest,
int offdest, unsigned numbytes);
程序例:
#include <mem.h>
#define MONO_BASE 0xB000
/* saves the contents of the monochrome screen in buffer */
void save_mono_screen(char near *buffer)
{
movedata(MONO_BASE, 0, _DS, (unsigned)buffer, 80*25*2);
}
int main(void)
{
char buf[80*25*2];
save_mono_screen(buf);
} 函数名: moverel
功 能:将当前位置(CP)移动一相对距离
用 法:
void far moverel(int dx, int dy);
程序例:
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
char msg[80];
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, );
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf(Graphics error: %s , grapherrormsg(errorcode));
printf(Press any key to halt:);
getch();
exit(1); /* terminate with an error code */
}
/* move the C.P. to location (20, 30) */
moveto(20, 30);
/* plot a pixel at the C.P. */
putpixel(getx(), gety(), getmaxcolor());
/* create and output a message at (20, 30) */
sprintf(msg, (%d, %d), getx(), gety());
outtextxy(20, 30, msg);
/* move to a point a relative distance */
/* away from the current value of C.P. */
moverel(100, 100);
/* plot a pixel at the C.P. */
putpixel(getx(), gety(), getmaxcolor());
/* create and output a message at C.P. */
sprintf(msg, (%d, %d), getx(), gety());
outtext(msg);
/* clean up */
getch();
closegraph();
return 0;
} 函数名: movetext
功 能:将屏幕文本从一个矩形区域拷贝到另一个矩形区域
用 法:
int movetext(int left, int top, int right, int bottom,
int newleft, int newtop);
程序例:
#include <conio.h>
#include <string.h>
int main(void)
{
char *str = This is a test string;
clrscr();
cputs(str);
getch();
movetext(1, 1, strlen(str), 2, 10, 10);
getch();
return 0;
} 函数名: moveto
功 能:将CP移到(x, y)
用 法:
void far moveto(int x, int y);
程序例:
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
char msg[80];
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, );
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf(Graphics error: %s , grapherrormsg(errorcode));
printf(Press any key to halt:);
getch();
exit(1); /* terminate with an error code */
}
/* move the C.P. to location (20, 30) */
moveto(20, 30);
/* plot a pixel at the C.P. */
putpixel(getx(), gety(), getmaxcolor());
/* create and output a message at (20, 30) */
sprintf(msg, (%d, %d), getx(), gety());
outtextxy(20, 30, msg);
/* move to (100, 100) */
moveto(100, 100);
/* plot a pixel at the C.P. */
putpixel(getx(), gety(), getmaxcolor());
/* create and output a message at C.P. */
sprintf(msg, (%d, %d), getx(), gety());
outtext(msg);
/* clean up */
getch();
closegraph();
return 0;
} 函数名: movemem
功 能:移动一块字节
用 法:
void movemem(void *source, void *destin, unsigned len);
程序例:
#include <mem.h>
#include <alloc.h>
#include <stdio.h>
#include <string.h>
int main(void)
{
char *source = Borland International;
char *destination;
int length;
length = strlen(source);
destination = malloc(length + 1);
movmem(source,destination,length);
printf(%s ,destination);
return 0;
} 函数名: normvideo
功 能:选择正常亮度字符
用 法:
void normvideo(void);
程序例:
#include <conio.h>
int main(void)
{
normvideo();
cprintf(NORMAL Intensity Text );
return 0;
} 函数名: nosound
功 能:关闭PC扬声器
用 法:
void nosound(void);
程序例:
/* Emits a 7-Hz tone for 10 seconds.
True story: 7 Hz is the resonant frequency of a chicken's skull cavity.
This was determined empirically in Australia, where a new factory
generating 7-Hz tones was located too close to a chicken ranch:
When the factory started up, all the chickens died.
Your PC may not be able to emit a 7-Hz tone.
*/
int main(void)
{
sound(7);
delay(10000);
nosound();
}

热点内容
华硕访问点 发布:2025-02-06 15:56:57 浏览:330
excel拼接sql 发布:2025-02-06 15:50:10 浏览:500
加密手机直播 发布:2025-02-06 15:49:31 浏览:534
自带ftp服务器好用吗 发布:2025-02-06 15:26:11 浏览:109
win7访问xp局域网 发布:2025-02-06 15:17:07 浏览:524
均线差算法 发布:2025-02-06 15:13:22 浏览:459
androidbrowser 发布:2025-02-06 15:09:49 浏览:622
勇敢的心ftp 发布:2025-02-06 15:09:03 浏览:327
php日志分析 发布:2025-02-06 15:08:19 浏览:874
36脚本大厅作者 发布:2025-02-06 14:55:53 浏览:409