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(\
return 0; }
函数名: asin
功 能: 反正弦函数
用 法: double asin(double x); 程序例:
#include
int main(void) {
double result; double x = 0.5;
result = asin(x);
printf(\ return(0); }
函数名: assert
功 能: 测试一个条件并可能使程序终止 用 法: void assert(int test); 程序例:
#include
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
功 能: 反正切函数
用 法: double atan(double x); 程序例:
#include
int main(void) {
double result; double x = 0.5;
result = atan(x);
printf(\ return(0); }
函数名: atan2
功 能: 计算Y/X的反正切值
用 法: double atan2(double y, double x); 程序例:
#include
int main(void) {
double result;
double x = 90.0, y = 45.0;
result = atan2(y, x);
printf(\ return 0; }
函数名: atexit
功 能: 注册终止函数
用 法: int atexit(atexit_t func); 程序例:
#include
void exit_fn1(void) {
printf(\ }
void exit_fn2(void) {
printf(\ }
int main(void) {
/* post exit function #1 */ atexit(exit_fn1);
/* post exit function #2 */ atexit(exit_fn2); return 0; }
函数名: atof
功 能: 把字符串转换成浮点数 用 法: double atof(const char *nptr); 程序例:
#include
int main(void) {
float f;
char *str = \
f = atof(str);
printf(\ return 0; }
函数名: atoi
功 能: 把字符串转换成长整型数 用 法: int atoi(const char *nptr); 程序例:
#include
int main(void) { int n;
char *str = \
n = atoi(str);
printf(\ return 0; }
函数名: atol
功 能: 把字符串转换成长整型数 用 法: long atol(const char *nptr); 程序例:
#include
int main(void) {
long l;
char *str = \
l = atol(lstr);
printf(\ return(0); }
C语言基础教程(三十三)
网上收集整理 函数篇(b)
函数名: bar
功 能: 画一个二维条形图
用 法: void far bar(int left, int top, int right, int bottom); 程序例:
#include
int main(void) {
/* request auto detection */
int gdriver = DETECT, gmode, errorcode; int midx, midy, i;
/* initialize graphics and local variables */ initgraph(&gdriver, &gmode, \
/* read result of initialization */ errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */ {
printf(\ printf(\ getch();
exit(1); /* terminate with an error code */ }
midx = getmaxx() / 2; midy = getmaxy() / 2;
/* loop through the fill patterns */
for (i=SOLID_FILL; i /* set the fill style */ setfillstyle(i, getmaxcolor()); /* draw the bar */ bar(midx-50, midy-50, midx+50, midy+50); getch();