stdlib.h
返回
stdlib.h
#include
#include
int main(void)
{
double ddt;
char ss[] = "78999.8";
ddt = atof(ss);
printf("%f\n", ddt);
return 0;
}
/*
运行结果
无时
4230120.000000
有时
78999.800000
*/
stdlib.h,srand
#include
#include
int main(void)
{
unsigned sd;
printf("Please input one number:");
scanf("%d", &sd);
srand(sd);
printf("sd=%d",sd);
return 0;
}
/*
运行结果
Please input one number:44
sd=44
*/
stdlib.h,abort
#include
#include /* for abort */
#include
int mystatus;
void myhandle(int sig)
{
printf("Signal %d started.\n", sig);
printf("status=%d, the program stopped.\n", mystatus);
printf("Please ask question with the NO.\n");
}
int main(void)
{
signal(SIGABRT, myhandle);
mystatus = 1234;
puts("----abort Front");
abort();
puts("----abort After");
return 0;
}
/*
运行结果
----abort Front
abnormal program termination
Signal 22 started.
status=1234, the program stopped.
Please ask question with the NO.BUFSIZ=512
abcdefghijABCDEFGHIJ
*/
stdlib.h,malloc,realloc
#include
#include
#include
void memput(char *p, int n)
{
int i;
for (i=0; i
stdlib.h,rand
#include
#include
#define RAND_MAX 0x7fff;
main(void)
{
double rand1;
rand1 = rand();
printf ("rand1=%f\n",rand1);
return 0;
}
/*
运行结果
rand1=41.000000
*/
/* Maximum value that can be returned by the rand function. */
#define RAND_MAX 0x7fff
#define RAND_MAX 0x7fff;
test090302.c(4) : warning C4005: 'RAND_MAX' : マクロが再定義されました。
C:\Program Files\Microsoft Visual Studio\VC98\include\stdlib.h(129) : 'R
AND_MAX' の前の定義を確認してください
Microsoft (R) Incremental Linker Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
返回