Neusoft Co,. Ltd.
h>
int main(void)
{
char buffer[80];
sprintf(buffer, "An approximation of Pi is %f\n", M_PI);
puts(buffer);
return 0;
}
return 0;
}
存储数组操作函数(memory.
输入输出函数(stdio.
{
FILE *stream;
stream = fopen("MYFILE.
if( (buffer = realloc( buffer, size + (1000 * sizeof( long )) )) == NULL )
h>
#include <string.
h> /* For _MAX_PATH definition */
h>
#include <math.
{
assert(itemptr != NULL);
"rt+" 打开一个文本文件,可读可写。
存储数组操作函数(memory.
动态存储分配(malloc.
"rb" 打开一个二进制文件,只能读。
用 法: int atoi(const char *nptr);
程序例:
#include <stdlib.
动态存储分配(malloc.h)
• 函数名: free
功 能: 释放已分配的块
用 法: void free(void *ptr);
程序例:
#include <string.h>
#include <stdio.h>
#include <malloc.h>
int main(void)
{
char *str;
/* allocate memory for string */
str = malloc(10);
/* copy "Hello" to string */
strcpy(str, "Hello");
/* display string */
printf("String is %s\n", str);
/* free memory */
free(str);
return 0;
}