存贮分配子程序,所在函数库为dos.h、alloc.h、malloc.h、stdlib.h、process.h
int allocmem(unsigned size,unsigned *seg)利用DOS分配空闲的内存,
size为分配内存大小,seg为分配后的内存指针
int freemem(unsigned seg)释放先前由allocmem分配的内存,seg为指定的内存指针
int setblock(int seg,int newsize)本函数用来修改所分配的内存长度,
seg为已分配内存的内存指针,newsize为新的长度
int brk(void *endds)
本函数用来改变分配给调用程序的数据段的空间数量,新的空间结束地址为endds
char *sbrk(int incr)
本函数用来增加分配给调用程序的数据段的空间数量,增加incr个字节的空间
unsigned long coreleft() 本函数返回未用的存储区的长度,以字节为单位
void *calloc(unsigned nelem,unsigned elsize)分配nelem个长度为elsize的内存空间
并返回所分配内存的指针
void *malloc(unsigned size)分配size个字节的内存空间,并返回所分配内存的指针
void free(void *ptr)释放先前所分配的内存,所要释放的内存的指针为ptr
void *realloc(void *ptr,unsigned newsize)改变已分配内存的大小,ptr为已分配有内
存区域的指针,newsize为新的长度,返回分配好的内存指针.
long farcoreleft() 本函数返回远堆中未用的存储区的长度,以字节为单位
void far *farcalloc(unsigned long units,unsigned long unitsz)
从远堆分配units个长度为unitsz的内存空间,并返回所分配内存的指针
void *farmalloc(unsigned long size)分配size个字节的内存空间,
并返回分配的内存指针
void farfree(void far *block)释放先前从远堆分配的内存空间,
所要释放的远堆内存的指针为block
void far *farrealloc(void far *block,unsigned long newsize)改变已分配的远堆内
存的大小,block为已分配有内存区域的指针,newzie为新的长度,返回分配好
的内存指针
时间日期函数,函数库为time.h、dos.h
在时间日期函数里,主要用到的结构有以下几个:
总时间日期贮存结构tm
┌──────────────────────┐
│struct tm │
│{ │
│ int tm_sec; /*秒,0-59*/ │
│ int tm_min; /*分,0-59*/ │
│ int tm_hour; /*时,0-23*/ │
│ int tm_mday; /*天数,1-31*/ │
│ int tm_mon; /*月数,0-11*/ │
│ int tm_year; /*自1900的年数*/ │
│ int tm_wday; /*自星期日的天数0-6*/ │
│ int tm_yday; /*自1月1日起的天数,0-365*/ │
│ int tm_isdst; /*是否采用夏时制,采用为正数*/│
│} │
└──────────────────────┘
日期贮存结构date
┌───────────────┐
│struct date │
│{ │
│ int da_year; /*自1900的年数*/│
│ char da_day; /*天数*/ │
│ char da_mon; /*月数 1=Jan*/ │
│} │
└───────────────┘
时间贮存结构time
┌────────────────┐
│struct time │
│{ │
│ unsigned char ti_min; /*分钟*/│
│ unsigned char ti_hour; /*小时*/│
│ unsigned char ti_hund; │
│ unsigned char ti_sec; /*秒*/ │
│ │
└────────────────┘
char *ctime(long *clock)
本函数把clock所指的时间(如由函数time返回的时间)转换成下列格式的
字符串:Mon Nov 21 11:31:54 1983/n/0
char *asctime(struct tm *tm)
本函数把指定的tm结构类的时间转换成下列格式的字符串:
Mon Nov 21 11:31:54 1983/n/0
double difftime(time_t time2,time_t time1)
计算结构time2和time1之间的时间差距(以秒为单位)
struct tm *gmtime(long *clock)本函数把clock所指的时间(如由函数time返回的时间)
转换成格林威治时间,并以tm结构形式返回
struct tm *localtime(long *clock)本函数把clock所指的时间(如函数time返回的时间)
转换成当地标准时间,并以tm结构形式返回
void tzset()本函数提供了对UNIX操作系统的兼容性
long dostounix(struct date *dateptr,struct time *timeptr)
本函数将dateptr所指的日期,timeptr所指的时间转换成UNIX格式,并返回
自格林威治时间1970年1月1日凌晨起到现在的秒数
void unixtodos(long utime,struct date *dateptr,struct time *timeptr)
本函数将自格林威治时间1970年1月1日凌晨起到现在的秒数utime转换成
DOS格式并保存于用户所指的结构dateptr和timeptr中
void getdate(struct date *dateblk)本函数将计算机内的日期写入结构dateblk
中以供用户使用
void setdate(struct date *dateblk)本函数将计算机内的日期改成
由结构dateblk所指定的日期
void gettime(struct time *timep)本函数将计算机内的时间写入结构timep中,
以供用户使用
void settime(struct time *timep)本函数将计算机内的时间改为
由结构timep所指的时间
long time(long *tloc)本函数给出自格林威治时间1970年1月1日凌晨至现在所经
过的秒数,并将该值存于tloc所指的单元中.
int stime(long *tp)本函数将tp所指的时间(例如由time所返回的时间)
写入计算机中.
分享到:
相关推荐
非标准头文件 alloc.h ,主要是区别malloc.h 两个头文件的区别,查看其而这区别 非标准头文件 alloc.h ,主要是区别malloc.h 两个头文件的区别,查看其而这区别
8.存贮分配子程序,所在函数库为dos.h、alloc.h、malloc.h、stdlib.h、process.h…………………19 9. 时间日期函数,所在函数库为time.h、dos.h………………………………………………………19
存贮分配子程序,所在函数库为dos.h、alloc.h、malloc.h、stdlib.h、process.h int allocmem(unsigned size,unsigned *seg)利用DOS 分配空闲的内存,size 为分配内存大小,seg 为分配后的内存指针 int freemem(unsigned...
1. Alloc.h 分配内存,使用二级配置器 2. TypeTraits.h 类型萃取 3. Construct.h 容器的构造和析构 4. Allocator.h alloc.h和construct.h的直接上级,封装函数 5. Itearator.h ...
exception.c exception.h gcalloc.h genlib.c genlib.h graphics.c graphics.h random.c random.h simpio.c simpio.h strlib.c strlib.h
下载的stl_alloc.h源码,自己加了注释,有助于理解stl空间配置器
gcalloc.h c语言自带习题库
#define LEFT 0x4B00 #define RIGHT 0x4D00 #define UP 0x4800 #define DOWN 0x5000 #define ESC 0x011B ...#include<alloc.h> #include<stdlib.h> #include<time.h> typedef char element; element map[20][20];
#include<alloc.h> int r; struct student { int number; char name[9]; float score[4]; float avescore; }; typedef struct link { struct student data; struct link *next; }LINK; LINK * Print(); ...
#include "stdio.h" /*I/O函数*/ # include "bios.h" /*ROM基本输入输出函数*/ #include "dos.h" /*dos接口函数*/ #include "conio.h" /*屏幕操作函数*/ ...#include "alloc.h" /*动态地址分配函数*/