China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-09-15 07:04
中国DOS联盟论坛 » DOS软件下载 & 游戏分享 (下载室) » Is there any software for learning Turbo C 2.0 under DOS? View 1,674 Replies 12
Original Poster Posted 2004-02-28 00:00 ·  中国 内蒙古 赤峰 联通
初级用户
Credits 107
Posts 2
Joined 2004-02-28 00:00
22-year member
UID 18678
Gender Male
Status Offline
Is there any software for learning Turbo C 2.0 under DOS?
Floor 2 Posted 2004-02-28 00:00 ·  中国 浙江 杭州 华数宽带
初级用户
★★
Credits 516
Posts 156
Joined 2003-07-28 00:00
23-year member
UID 7657
Gender Male
Status Offline
There seem to be some for learning C, but not for tc. It's still better to buy a book.
Floor 3 Posted 2004-02-29 00:00 ·  中国 河北 廊坊 联通
中级用户
★★
Credits 334
Posts 56
Joined 2004-01-04 00:00
22-year member
UID 14870
Gender Male
Status Offline
the c programing language
http://wendos.mycool.net
http://firststep.mycool.net
PM me
Floor 4 Posted 2004-05-17 00:00 ·  中国 浙江 杭州 电信
初级用户
Credits 112
Posts 3
Joined 2004-05-16 00:00
22-year member
UID 24517
Gender Male
Status Offline
You can download it from some sites such as Sky Software Station and Huajun Software Garden. I installed it today, and it's very easy to use!!
Floor 5 Posted 2004-05-18 00:00 ·  中国 辽宁 朝阳 联通
铂金会员
★★★★
痴迷DOS者
Credits 5,798
Posts 1,924
Joined 2003-06-20 00:00
23-year member
UID 5583
Gender Male
From 金獅電腦軟體工作室
Status Offline
Classification functions, in the function library ctype.h
int isalpha(int ch) if ch is a letter ('A'-'Z','a'-'z' it returns a non-0 value, otherwise it returns 0
int isalnum(int ch) if ch is a letter ('A'-'Z','a'-'z' or a digit ('0'-'9', it returns a non-0 value, otherwise it returns 0
int isascii(int ch) if ch is a character (0-127 in the ASCII code) it returns a non-0 value, otherwise it returns 0
int iscntrl(int ch) if ch is a delete character (0x7F) or an ordinary control character (0x00-0x1F), it returns a non-0 value, otherwise it returns 0
int isdigit(int ch) if ch is a digit ('0'-'9' it returns a non-0 value, otherwise it returns 0
int isgraph(int ch) if ch is a printable character (excluding space) (0x21-0x7E) it returns a non-0 value, otherwise it returns 0
int islower(int ch) if ch is a lowercase letter ('a'-'z' it returns a non-0 value, otherwise it returns 0
int isprint(int ch) if ch is a printable character (including space) (0x20-0x7E) it returns a non-0 value, otherwise it returns 0
int ispunct(int ch) if ch is a punctuation character (0x00-0x1F) it returns a non-0 value, otherwise it returns 0
int isspace(int ch) if ch is a space (' ', horizontal tab ('\t', carriage return ('\r', form feed ('\f', vertical tab ('\v', or newline ('\n', it returns a non-0 value, otherwise it returns 0
int isupper(int ch) if ch is an uppercase letter ('A'-'Z' it returns a non-0 value, otherwise it returns 0
int isxdigit(int ch) if ch is a hexadecimal number ('0'-'9','A'-'F','a'-'f' it returns a non-0 value, otherwise it returns 0
int tolower(int ch) if ch is an uppercase letter ('A'-'Z' it returns the corresponding lowercase letter ('a'-'z'
int toupper(int ch) if ch is a lowercase letter ('a'-'z' it returns the corresponding uppercase letter ('A'-'Z'

Math functions, in the function libraries math.h, stdlib.h, string.h, float.h
int abs(int i) returns the absolute value of integer parameter i
double cabs(struct complex znum) returns the absolute value of complex number znum
double fabs(double x) returns the absolute value of double-precision parameter x
long labs(long n) returns the absolute value of long integer parameter n
double exp(double x) returns the value of the exponential function ex
double frexp(double value,int *eptr) returns the value of x in value=x*2n, n is stored in eptr
double ldexp(double value,int exp); returns the value of value*2exp
double log(double x) returns the value of logex
double log10(double x) returns the value of log10x
double pow(double x,double y) returns the value of xy
double pow10(int p) returns the value of 10p
double sqrt(double x) returns the square root of x
double acos(double x) returns the inverse cosine value cos-1(x) of x, x is in radians
double asin(double x) returns the inverse sine value sin-1(x) of x, x is in radians
double atan(double x) returns the inverse tangent value tan-1(x) of x, x is in radians
double atan2(double y,double x) returns the inverse tangent value tan-1(x) of y/x, x and y are in radians
double cos(double x) returns the cosine value cos(x) of x, x is in radians
double sin(double x) returns the sine value sin(x) of x, x is in radians
double tan(double x) returns the tangent value tan(x) of x, x is in radians
double cosh(double x) returns the hyperbolic cosine value cosh(x) of x, x is in radians
double sinh(double x) returns the hyperbolic sine value sinh(x) of x, x is in radians
double tanh(double x) returns the hyperbolic tangent value tanh(x) of x, x is in radians
double hypot(double x,double y) returns the length of the hypotenuse (z) of a right triangle, x and y are the lengths of the legs, z2=x2+y2
double ceil(double x) returns the smallest integer not less than x
double floor(double x) returns the largest integer not greater than x
void srand(unsigned seed) initializes the random number generator
int rand() generates a random number and returns it
double poly(double x,int n,double c) generates a polynomial from the parameters
double modf(double value,double *iptr) splits double-precision value into mantissa and exponent
double fmod(double x,double y) returns the remainder of x/y
double frexp(double value,int *eptr) splits double-precision value into mantissa and exponent
double atof(char *nptr) converts string nptr to a floating-point number and returns it
double atoi(char *nptr) converts string nptr to an integer and returns it
double atol(char *nptr) converts string nptr to a long integer and returns it
char *ecvt(double value,int ndigit,int *decpt,int *sign)
converts floating-point value to a string and returns that string
char *fcvt(double value,int ndigit,int *decpt,int *sign)
converts floating-point value to a string and returns that string
char *gcvt(double value,int ndigit,char *buf)
converts value to a string and stores it in buf, and returns a pointer to buf
char *ultoa(unsigned long value,char *string,int radix)
converts unsigned integer value to a string and returns that string, radix is the base used in conversion
char *ltoa(long value,char *string,int radix)
converts long integer value to a string and returns that string, radix is the base used in conversion
char *itoa(int value,char *string,int radix)
converts integer value to a string and stores it in string, radix is the base used in conversion
double atof(char *nptr) converts string nptr to a double-precision number and returns it, returns 0 on error
int atoi(char *nptr) converts string nptr to an integer and returns it, returns 0 on error
long atol(char *nptr) converts string nptr to a long integer and returns it, returns 0 on error
double strtod(char *str,char **endptr)converts string str to a double-precision number and returns it,
long strtol(char *str,char **endptr,int base)converts string str to a long integer and returns it,
int matherr(struct exception *e) user-modified math error return message function (not necessary to use)
double _matherr(_mexcep why,char *fun,double *arg1p, double *arg2p,double retval)
user-modified math error return message function (not necessary to use)
unsigned int _clear87() clears the floating-point status word and returns the original floating-point status
void _fpreset() reinitializes the floating-point math package
unsigned int _status87() returns the floating-point status word
熟能生巧,巧能生精,一艺不精,终生无成,精亦求精,始有所成,臻于完美,永无止境!
金狮電腦軟體工作室愿竭诚为您服务!
QQ群:8393170(定期清理不发言者)
个人网站:http://www.520269.cn
电子邮件:doujiehui@vip.qq.com
微信公众号: doujiehui
Floor 6 Posted 2004-05-18 00:00 ·  中国 辽宁 朝阳 联通
铂金会员
★★★★
痴迷DOS者
Credits 5,798
Posts 1,924
Joined 2003-06-20 00:00
23-year member
UID 5583
Gender Male
From 金獅電腦軟體工作室
Status Offline
Directory functions, in the function libraries dir.h and dos.h
int chdir(char *path) makes the specified directory path (for example: "C:\\WPS" the current working directory, returns 0 on success
int findfirst(char *pathname,struct ffblk *ffblk,int attrib)
searches for the specified file, returns 0 on success
pathname is the specified directory name and file name, such as "C:\\WPS\\TXT"
ffblk is a structure used to save file information, defined as follows:
┏━━━━━━━━━━━━━━━━━━┓
┃struct ffblk ┃
┃{ ┃
┃ char ff_reserved; /*DOS reserved words*/┃
┃ char ff_attrib; /*file attributes*/ ┃
┃ int ff_ftime; /*file time*/ ┃
┃ int ff_fdate; /*file date*/ ┃
┃ long ff_fsize; /*file length*/ ┃
┃ char ff_name; /*file name*/ ┃
┃} ┃
┗━━━━━━━━━━━━━━━━━━┛
attrib is the file attribute, represented by the following characters
┏━━━━━━━━━┳━━━━━━━━┓
┃FA_RDONLY read-only file┃FA_LABEL volume label┃
┃FA_HIDDEN hidden file┃FA_DIREC directory ┃
┃FA_SYSTEM system file┃FA_ARCH archive ┃
┗━━━━━━━━━┻━━━━━━━━┛
Example:
struct ffblk ff;
findfirst("*.wps",&ff,FA_RDONLY);

int findnext(struct ffblk *ffblk) gets the file matching finddirst, returns 0 on success
void fumerge(char *path,char *drive,char *dir,char *name,char *ext)
this function composes a file name from drive (C:, A:, etc.), path dir (\TC, \BC\LIB, etc.), file name name (TC, WPS, etc.), and extension ext (.EXE, .COM, etc.), and stores it in path.
int fnsplit(char *path,char *drive,char *dir,char *name,char *ext)
this function splits file name path into drive (C:, A:, etc.), path dir (\TC, \BC\LIB, etc.), file name name (TC, WPS, etc.), and extension ext (.EXE, .COM, etc.), and stores them into the corresponding variables.
int getcurdir(int drive,char *direc)
this function returns the name of the current working directory on the specified drive. Returns 0 on success
drive is the specified drive (0=current,1=A,2=B,3=C, etc.)
direc is the variable used to save the current working path of the specified drive
char *getcwd(char *buf,iint n) this function gets the current working directory and stores it in buf, up to n bytes in length. Returns NULL on error
int getdisk() gets the drive currently in use and returns an integer (0=A,1=B,2=C, etc.)
int setdisk(int drive) sets the drive to use drive (0=A,1=B,2=C, etc.), returns the total number of usable drives
int mkdir(char *pathname) creates a new directory pathname, returns 0 on success
int rmdir(char *pathname) deletes a directory pathname, returns 0 on success
char *mktemp(char *template) constructs a file name that does not exist in the current directory and stores it in template
char *searchpath(char *pathname) uses MSDOS to find the path where file filename is located, this function uses DOS's PATH variable, returns NULL if the file is not found

Process functions, in the function libraries stdlib.h and process.h
void abort() this function writes a termination message to stderr by calling _exit with exit code 3, and terminates the program abnormally. No return value

int exec…loads and runs other programs
int execl(char *pathname,char *arg0,char *arg1,…,char *argn,NULL)
int execle(char *pathname,char *arg0,char *arg1,…, char *argn,NULL,char *envp)
int execlp(char *pathname,char *arg0,char *arg1,…,NULL)
int execlpe(char *pathname,char *arg0,char *arg1,…,NULL,char *envp)
int execv(char *pathname,char *argv)
int execve(char *pathname,char *argv,char *envp)
int execvp(char *pathname,char *argv)
int execvpe(char *pathname,char *argv,char *envp)

The exec function family loads and runs program pathname, and passes parameters arg0(arg1,arg2,argv,envp) to the subprogram, returns -1 on error.
In the exec function family, when the suffixes l, v, p, e are added after exec, the specified function will have a certain operating capability.
With suffix p, the function can use DOS's PATH variable to search for subprogram files.
l means the number of parameters passed in the function is fixed.
v means the number of parameters passed in the function is not fixed.
e means the function passes the specified parameter envp, allowing the environment of the child process to be changed.
Without suffix e, the child process uses the environment of the current program.

void _exit(int status) terminates the current program, but does not clean up the environment
void exit(int status) terminates the current program, closes all files, writes the output in the buffer (waiting for output), and calls any registered "exit functions", no return value

int spawn…runs a subprogram
int spawnl(int mode,char *pathname,char *arg0,char *arg1,…, char *argn,NULL)
int spawnle(int mode,char *pathname,char *arg0,char *arg1,…, char *argn,NULL,char *envp)
int spawnlp(int mode,char *pathname,char *arg0,char *arg1,…, char *argn,NULL)
int spawnlpe(int mode,char *pathname,char *arg0,char *arg1,…, char *argn,NULL,char *envp)
int spawnv(int mode,char *pathname,char *argv)
int spawnve(int mode,char *pathname,char *argv,char *envp)
int spawnvp(int mode,char *pathname,char *argv)
int spawnvpe(int mode,char *pathname,char *argv,char *envp)

The spawn function family runs subprogram pathname in mode mode, and passes parameters arg0(arg1,arg2,argv,envp) to the subprogram. Returns -1 on error
mode is the run mode:
mode is P_WAIT means returning to this program after the subprogram finishes running
P_NOWAIT means this program runs at the same time as the subprogram is running (unusable)
P_OVERLAY means running the subprogram after this program exits

In the spawn function family, when the suffixes l, v, p, e are added after spawn, the specified function will have a certain operating capability
With suffix p, the function uses DOS's PATH to search for subprogram files
l means the function passes a fixed number of parameters.
v means the function passes a variable number of parameters.
e means the specified parameter envp can be passed to the subprogram, allowing the subprogram's runtime environment to be changed.
Without suffix e, the subprogram uses the environment of this program.

int system(char *command)
passes MSDOS command command to DOS for execution by a conversion subprogram, function libraries are math.h, stdlib.h, ctype.h, float.h
char *ecvt(double value,int ndigit,int *decpt,int *sign)
converts floating-point value to a string and returns that string
char *fcvt(double value,int ndigit,int *decpt,int *sign)
converts floating-point value to a string and returns that string
char *gcvt(double value,int ndigit,char *buf)
converts value to a string and stores it in buf, and returns a pointer to buf
char *ultoa(unsigned long value,char *string,int radix)
converts unsigned integer value to a string and returns that string, radix is the base used in conversion
char *ltoa(long value,char *string,int radix)
converts long integer value to a string and returns that string, radix is the base used in conversion
char *itoa(int value,char *string,int radix)
converts integer value to a string and stores it in string, radix is the base used in conversion
double atof(char *nptr) converts string nptr to a double-precision number and returns it, returns 0 on error
int atoi(char *nptr) converts string nptr to an integer and returns it, returns 0 on error
long atol(char *nptr) converts string nptr to a long integer and returns it, returns 0 on error
double strtod(char *str,char **endptr)
converts string str to a double-precision number and returns it,
long strtol(char *str,char **endptr,int base)
converts string str to a long integer and returns it,
int toascii(int c) returns the corresponding ASCII of c
int tolower(int ch) if ch is an uppercase letter ('A'-'Z' it returns the corresponding lowercase letter ('a'- 'z'
int _tolower(int ch) returns the corresponding lowercase letter ('a'-'z' of ch
int toupper(int ch) if ch is a lowercase letter ('a'-'z' it returns the corresponding uppercase letter ('A'- 'Z'
int _toupper(int ch) returns the corresponding uppercase letter ('A'-'Z' of ch
熟能生巧,巧能生精,一艺不精,终生无成,精亦求精,始有所成,臻于完美,永无止境!
金狮電腦軟體工作室愿竭诚为您服务!
QQ群:8393170(定期清理不发言者)
个人网站:http://www.520269.cn
电子邮件:doujiehui@vip.qq.com
微信公众号: doujiehui
Floor 7 Posted 2004-05-18 00:00 ·  中国 辽宁 朝阳 联通
铂金会员
★★★★
痴迷DOS者
Credits 5,798
Posts 1,924
Joined 2003-06-20 00:00
23-year member
UID 5583
Gender Male
From 金獅電腦軟體工作室
Status Offline
Diagnostic functions, in the function libraries assert.h and math.h
void assert(int test) a macro expanded much like an if statement; if the test fails, it displays a message and terminates the program abnormally, no return value
void perror(char *string) this function displays the most recent error message, in the format: string string:error message
char *strerror(char *str) this function returns the most recent error message, in the format: string str:error message
int matherr(struct exception *e)
user-modified math error return message function (not necessary to use)
double _matherr(_mexcep why,char *fun,double *arg1p, double *arg2p,double retval)
user-modified math error return message function (not necessary to use)

Input/output subroutines, function libraries are io.h, conio.h, stat.h, dos.h, stdio.h, signal.h

int kbhit() this function returns the most recently pressed key
int fgetchar() reads one character from the console (keyboard), displaying it on the screen
int getch() reads one character from the console (keyboard), without displaying it on the screen
int putch() writes one character to the console (keyboard)
int getchar() reads one character from the console (keyboard), displaying it on the screen
int putchar() writes one character to the console (keyboard)
int getche() reads one character from the console (keyboard), displaying it on the screen
int ungetch(int c) pushes character c back to the console (keyboard)
char *cgets(char *string) reads a string from the console (keyboard) and stores it in string
int scanf(char *format)
reads a string from the console, assigns values to each parameter, and uses BIOS for output
int vscanf(char *format,Valist param)
reads a string from the console, assigns values to each parameter, and uses BIOS for output, parameters are taken from Valist param
int cscanf(char *format)
reads a string from the console, assigns values to each parameter, and operates directly on the console, for example when the display is showing characters it uses direct video memory writing for display
int sscanf(char *string,char *format)
assigns values to each parameter through string string
int vsscanf(char *string,char *format,Vlist param)
assigns values to each parameter through string string, parameters are taken from Vlist param
int puts(char *string) sends a string string to the console (display), using BIOS for output
void cputs(char *string) sends a string string to the console (display), operating directly on the console, for example the display uses direct video memory writing for display
int printf(char *format)
sends formatted string output to the console (display), using BIOS for output
int vprintf(char *format,Valist param)
sends formatted string output to the console (display), using BIOS for output, parameters are taken from Valist param
int cprintf(char *format)
sends formatted string output to the console (display), operating directly on the console, for example the display uses direct video memory writing for display
int vcprintf(char *format,Valist param)
sends formatted string output to the console (display), operating directly on the console, for example the display uses direct video memory writing for display, parameters are taken from Valist param
int sprintf(char *string,char *format)
replaces the contents of string string with the formatted string
int vsprintf(char *string,char *format,Valist param)
replaces the contents of string string with the formatted string, parameters are taken from Valist param
int rename(char *oldname,char *newname)changes the name of file oldname to newname
int ioctl(int handle,int cmd)
this function is used to control input/output devices, see the table below:
┌───┬────────────────────────────┐
│cmd value │function │
├───┼────────────────────────────┤
│ 0 │get device information │
│ 1 │set device information │
│ 2 │read argcx bytes into the address pointed to by argdx │
│ 3 │write argcx bytes to the address pointed to by argdx │
│ 4 │same as cmd=2 except handle is treated as a device number (0=current,1=A, etc.) │
│ 5 │same as cmd=3 except handle is treated as a device number (0=current,1=A, etc.) │
│ 6 │get input status │
│ 7 │get output status │
│ 8 │test removability; DOS 3.x only │
│ 11 │set retry count for share conflicts; DOS 3.x only │
└───┴────────────────────────────┘
int (*ssignal(int sig,int(*action)())() executes a software signal (not necessary to use)
int gsignal(int sig) executes a software signal (not necessary to use)

int _open(char *pathname,int access)opens a file for reading or writing, and uses access to determine whether it is opened for reading or writing, see the table below for access values
┌──────┬────────────────────┐
│access value │meaning │
├──────┼────────────────────┤
│O_RDONLY │read file │
│O_WRONLY │write file │
│O_RDWR │read and write │
│O_NOINHERIT │included if the file is not passed to the subprogram │
│O_DENYALL │only allow the current process to access the file │
│O_DENYWRITE │only allow reading from any other opened file │
│O_DENYREAD │only allow writing from any other opened file │
│O_DENYNONE │allow other shared opens of the file │
└──────┴────────────────────┘
int open(char *pathname,int access)opens a file for reading or writing, and uses access to determine whether it is opened for reading or writing, see the table below for access values
┌────┬────────────────────┐
│access value│meaning │
├────┼────────────────────┤
│O_RDONLY│read file │
│O_WRONLY│write file │
│O_RDWR │read and write │
│O_NDELAY│unused; for UNIX system compatibility │
│O_APPEND│read and write, but each write always appends at the end of the file │
│O_CREAT │if the file exists, this flag is useless; if it does not exist, create a new file │
│O_TRUNC │if the file exists, its length is truncated to 0, attributes unchanged │
│O_EXCL │unused; for UNIX system compatibility │
│O_BINARY│this flag can explicitly specify opening the file in binary mode │
│O_TEXT │this flag can be used to explicitly specify opening the file in text mode│
└────┴────────────────────┘
permiss is the file attribute, and can be one of the following values:
S_IWRITE allows writing S_IREAD allows reading S_IREAD|S_IWRITE allows reading and writing
int creat(char *filename,int permiss) creates a new file filename and sets its readability/writability.
permiss is the file readability/writability, and can be one of the following values
S_IWRITE allows writing S_IREAD allows reading S_IREAD|S_IWRITE allows reading and writing
int _creat(char *filename,int attrib) creates a new file filename and sets file attributes.
attrib is the file attribute, and can be one of the following values
FA_RDONLY read-only FA_HIDDEN hidden FA_SYSTEM system
int creatnew(char *filenamt,int attrib) creates a new file filename and sets file attributes.
attrib is the file attribute, and can be one of the following values
FA_RDONLY read-only FA_HIDDEN hidden FA_SYSTEM system
int creattemp(char *filenamt,int attrib) creates a new file filename and sets file attributes.
attrib is the file attribute, and can be one of the following values
FA_RDONLY read-only FA_HIDDEN hidden FA_SYSTEM system
int read(int handle,void *buf,int nbyte) reads nbyte characters from the file with file number handle into buf
int _read(int handle,void *buf,int nbyte) reads nbyte characters from the file with file number handle into buf, directly calling MSDOS to operate.
int write(int handle,void *buf,int nbyte) writes nbyte characters from buf into the file with file number handle
int _write(int handle,void *buf,int nbyte) writes nbyte characters from buf into the file with file number handle
int dup(int handle) duplicates a file handle handle and returns this handle
int dup2(int handle,int newhandle) duplicates file handle handle to newhandle
int eof(int *handle) checks whether the file has ended, returns 1 if ended, otherwise returns 0
long filelength(int handle) returns the file length, handle is the file number
int setmode(int handle,unsigned mode)this function is used to set the opening mode of the file with file number handle
int getftime(int handle,struct ftime *ftime)
reads the time of the file with file number handle, and stores the file time in structure ftime, returns 0 on success, ftime structure is as follows:
┌─────────────────┐
│struct ftime │
│{ │
│ unsigned ft_tsec:5; /*seconds*/ │
│ unsigned ft_min:6; /*minutes*/ │
│ unsigned ft_hour:5; /*hours*/ │
│ unsigned ft_day:5; /*day*/ │
│ unsigned ft_month:4;/*month*/ │
│ unsigned ft_year:1; /*year-1980*/ │
│} │
└─────────────────┘
int setftime(int handle,struct ftime *ftime) rewrites the file time of the file with file number handle,
the new time is in structure ftime. Returns 0 on success. The structure ftime is as follows:
┌─────────────────┐
│struct ftime │
│{ │
│ unsigned ft_tsec:5; /*seconds*/ │
│ unsigned ft_min:6; /*minutes*/ │
│ unsigned ft_hour:5; /*hours*/ │
│ unsigned ft_day:5; /*day*/ │
│ unsigned ft_month:4;/*month*/ │
│ unsigned ft_year:1; /*year-1980*/ │
│} │
└─────────────────┘
long lseek(int handle,long offset,int fromwhere)
this function moves the pointer of the file with file number handle to the offset-th byte after fromwhere.
SEEK_SET file switch SEEK_CUR current position SEEK_END end of file
long tell(int handle) this function returns the file pointer of the file with file number handle, in bytes
int isatty(int handle)this function is used to get the type of device handle
int lock(int handle,long offset,long length) locks file sharing
int unlock(int handle,long offset,long length) unlocks file sharing

int close(int handle) closes the file handle represented by handle, handle is a file handle obtained from one of _creat, creat,
creatnew, creattemp, dup, dup2, _open, open
returns 0 on success, otherwise returns -1, usable on UNIX systems
int _close(int handle) closes the file handle represented by handle, handle is a file handle obtained from one of _creat, creat,
creatnew, creattemp, dup, dup2, _open, open
returns 0 on success, otherwise returns -1, usable only on MSDOS systems

FILE *fopen(char *filename,char *type) opens a file filename, with opening mode type,
and returns this file pointer, type can be one of the following strings plus a suffix
┌──┬────┬───────┬────────┐
│type│read/write │text/binary file│create new/open old file │
├──┼────┼───────┼────────┤
│r │read │text │open old file │
│w │write │text │create new file │
│a │append │text │open if it exists, otherwise create new│
│r+ │read/write │unrestricted │open │
│w+ │read/write │unrestricted │create new file │
│a+ │read/append │unrestricted │open if it exists, otherwise create new│
└──┴────┴───────┴────────┘
the suffixes that can be added are t and b. Adding b means the file is operated in binary form; t is not necessary to use
Example: ┌──────────────────┐
│#include │
│main() │
│{ │
│ FILE *fp; │
│ fp=fopen("C:\\WPS\\WPS.EXE","r+b";│
└──────────────────┘
FILE *fdopen(int ahndle,char *type)
FILE *freopen(char *filename,char *type,FILE *stream)
int getc(FILE *stream) reads one character from stream stream, and returns that character
int putc(int ch,FILE *stream) writes one character ch to stream stream
int getw(FILE *stream) reads an integer from stream stream, returns EOF on error
int putw(int w,FILE *stream) writes an integer to stream stream
int ungetc(char c,FILE *stream) pushes character c back to stream stream, the next character read will be c
int fgetc(FILE *stream) reads one character from stream stream, and returns that character
int fputc(int ch,FILE *stream) writes character ch into stream stream
char *fgets(char *string,int n,FILE *stream)
reads n characters from stream stream into string
int fputs(char *string,FILE *stream)writes string string into stream stream
int fread(void *ptr,int size,int nitems,FILE *stream)
reads nitems strings of length size from stream stream into ptr
int fwrite(void *ptr,int size,int nitems,FILE *stream)
writes nitems strings of length size to stream stream, the strings are in ptr
int fscanf(FILE *stream,char *format)
reads a string from stream stream in formatted form
int vfscanf(FILE *stream,char *format,Valist param)
reads a string from stream stream in formatted form, parameters are taken from Valist param
int fprintf(FILE *stream,char *format)
writes a string to the specified stream stream in formatted form
int vfprintf(FILE *stream,char *format,Valist param)
writes a string to the specified stream stream in formatted form, parameters are taken from Valist param
int fseek(FILE *stream,long offset,int fromwhere)
the function moves the file pointer to the offset-th byte after the position pointed to by fromwhere, fromwhere can be one of the following values:
SEEK_SET file switch SEEK_CUR current position SEEK_END end of file
long ftell(FILE *stream) the function returns the current file pointer position in stream, in bytes
int rewind(FILE *stream) moves the current file pointer stream to the beginning of the file
int feof(FILE *stream) checks whether the file pointer on stream stream is at the end position
int fileno(FILE *stream) gets the file handle on stream stream and returns the file handle
int ferror(FILE *stream) checks whether there is a read/write error on stream stream, returns 1 if there is an error
void clearerr(FILE *stream) clears read/write errors on stream stream
void setbuf(FILE *stream,char *buf) assigns buffer buf to stream stream
void setvbuf(FILE *stream,char *buf,int type,unsigned size)
assigns buffer buf to stream stream, size is size, type is type, see the table below for type values

┌───┬───────────────────────────────┐
│type value│meaning │
├───┼───────────────────────────────┤
│_IOFBF│the file is fully buffered; when the buffer is empty, the next input operation will try to fill the entire buffer│
│ │. On output, the buffer will be completely filled before any data is written to the file. │
│_IOLBF│the file is line buffered. When the buffer is empty, the next input operation will still try to fill the entire buf│
│ │fer. However, on output, whenever a newline character is written to the file, the buffer is flushed. │
│_IONBF│the file is unbuffered. The buf and size parameters are ignored. Each input operation reads directly from the fi│
│ │le, and each output operation immediately writes data to the file. │
└───┴───────────────────────────────┘
int fclose(FILE *stream) closes a stream, which may be a file or a device (for example LPT1)
int fcloseall() closes all streams except stdin or stdout
int fflush(FILE *stream)
closes a stream, and processes the buffer: for a read stream, reads the contents of the stream into the buffer; for a write stream, writes the contents of the buffer into the stream. Returns 0 on success
int fflushall()
closes all streams, and processes each stream's buffer: for a read stream, reads the contents of the stream into the buffer; for a write stream, writes the contents of the buffer into the stream. Returns 0 on success
int access(char *filename,int amode)
this function checks file filename and returns the file's attributes, the function stores the attributes in amode, amode is composed of the following bit combinations
06 readable and writable 04 readable 02 writable 01 executable (ignored) 00 file exists
if filename is a directory, the function only determines whether the directory exists; the function returns 0 on success, otherwise returns -1
int chmod(char *filename,int permiss) this function is used to set the attributes of file filename
permiss can be one of the following values
S_IWRITE allows writing S_IREAD allows reading S_IREAD|S_IWRITE allows reading and writing
int _chmod(char *filename,int func);
this function is used to read or set the attributes of file filename,
when func=0, the function returns the attributes of the file; when func=1, the function sets the attributes of the file
if setting file attributes, attrib can be one of the following constants
FA_RDONLY read-only FA_HIDDEN hidden FA_SYSTEM system
熟能生巧,巧能生精,一艺不精,终生无成,精亦求精,始有所成,臻于完美,永无止境!
金狮電腦軟體工作室愿竭诚为您服务!
QQ群:8393170(定期清理不发言者)
个人网站:http://www.520269.cn
电子邮件:doujiehui@vip.qq.com
微信公众号: doujiehui
Floor 8 Posted 2004-05-18 00:00 ·  中国 辽宁 朝阳 联通
铂金会员
★★★★
痴迷DOS者
Credits 5,798
Posts 1,924
Joined 2003-06-20 00:00
23-year member
UID 5583
Gender Male
From 金獅電腦軟體工作室
Status Offline
熟能生巧,巧能生精,一艺不精,终生无成,精亦求精,始有所成,臻于完美,永无止境!
金狮電腦軟體工作室愿竭诚为您服务!
QQ群:8393170(定期清理不发言者)
个人网站:http://www.520269.cn
电子邮件:doujiehui@vip.qq.com
微信公众号: doujiehui
Floor 9 Posted 2004-05-18 00:00 ·  中国 辽宁 朝阳 联通
铂金会员
★★★★
痴迷DOS者
Credits 5,798
Posts 1,924
Joined 2003-06-20 00:00
23-year member
UID 5583
Gender Male
From 金獅電腦軟體工作室
Status Offline
str…string operation functions
char stpcpy(char *dest,const char *src) copies string src to dest
char strcat(char *dest,const char *src) appends string src to the end of dest
char strchr(const char *s,int c) searches for and returns the position of the first occurrence of character c in string s
int strcmp(const char *s1,const char *s2) compares strings s1 and s2, and returns s1-s2
char strcpy(char *dest,const char *src) copies string src to dest
size_t strcspn(const char *s1,const char *s2) scans s1 and returns the number of characters that are present in both s1 and s2
char strdup(const char *s) copies string s to the most recently created unit
int stricmp(const char *s1,const char *s2) compares strings s1 and s2, and returns s1-s2
size_t strlen(const char *s) returns the length of string s
char strlwr(char *s)
converts all uppercase letters in string s to lowercase letters and returns the converted string
char strncat(char *dest,const char *src,size_t maxlen)
copies at most maxlen characters from string src into string dest
int strncmp(const char *s1,const char *s2,size_t maxlen)
compares the first maxlen characters in strings s1 and s2
char strncpy(char *dest,const char *src,size_t maxlen)
copies the first maxlen characters in src to dest
int strnicmp(const char *s1,const char *s2,size_t maxlen)
compares the first maxlen characters in strings s1 and s2
char strnset(char *s,int ch,size_t n)
sets the first n characters of string s to ch
char strpbrk(const char *s1,const char *s2)
scans string s1 and returns the number of characters that are present in both s1 and s2
char strrchr(const char *s,int c)
scans a string s for the last occurrence of a given character c
char strrev(char *s)
reverses the order of all characters in string s and returns the rearranged string
char strset(char *s,int ch)
sets all characters in a string s to a given character ch
size_t strspn(const char *s1,const char *s2)
scans string s1 and returns the number of characters that are present in both s1 and s2
char strstr(const char *s1,const char *s2)
scans string s2 and returns the position of the first occurrence of s1
char strtok(char *s1,const char *s2)
searches string s1, where string s1 is separated by delimiters defined in string s2
char strupr(char *s)
converts all lowercase letters in string s to uppercase letters and returns the converted string

Memory allocation subroutines, in the function libraries dos.h, alloc.h, malloc.h, stdlib.h, process.h
int allocmem(unsigned size,unsigned *seg)
uses DOS to allocate free memory, size is the size of memory to allocate, seg is the allocated memory pointer
int freemem(unsigned seg)
releases memory previously allocated by allocmem, seg is the specified memory pointer
int setblock(int seg,int newsize)
this function is used to modify the length of allocated memory, seg is the memory pointer of the allocated memory, newsize is the new length
int brk(void *endds)
this function is used to change the amount of space allocated to the calling program's data segment, the end address of the new space is endds
char *sbrk(int incr)
this function is used to increase the amount of space allocated to the calling program's data segment, increasing by incr bytes
unsigned long coreleft() this function returns the length of unused storage area, in bytes
void *calloc(unsigned nelem,unsigned elsize)
allocates memory space for nelem elements of length elsize and returns a pointer to the allocated memory
void *malloc(unsigned size) allocates memory space of size bytes and returns a pointer to the allocated memory
void free(void *ptr) releases previously allocated memory, ptr is the pointer to the memory to be released
void *realloc(void *ptr,unsigned newsize)
changes the size of allocated memory, ptr is the pointer to an already allocated memory area, newsize is the new length, returns the allocated memory pointer.
long farcoreleft() this function returns the length of unused storage area in the far heap, in bytes
void far *farcalloc(unsigned long units,unsigned long unitsz)
allocates memory space for units units of length unitsz from the far heap, and returns a pointer to the allocated memory
void *farmalloc(unsigned long size)
allocates memory space of size bytes, and returns the allocated memory pointer
void farfree(void far *block)
releases memory space previously allocated from the far heap, block is the pointer to the far heap memory to be released
void far *farrealloc(void far *block,unsigned long newsize)
changes the size of allocated far heap memory, block is the pointer to an already allocated memory area, newzie is the new length, returns the allocated memory pointer

Time and date functions, function libraries are time.h and dos.h
In the time and date functions, the following structures are mainly used:
Overall time/date storage structure tm
┌──────────────────────┐
│struct tm │
│{ │
│ int tm_sec; /*seconds,0-59*/ │
│ int tm_min; /*minutes,0-59*/ │
│ int tm_hour; /*hours,0-23*/ │
│ int tm_mday; /*day of month,1-31*/ │
│ int tm_mon; /*month,0-11*/ │
│ int tm_year; /*years since 1900*/ │
│ int tm_wday; /*days since Sunday 0-6*/ │
│ int tm_yday; /*days since January 1,0-365*/ │
│ int tm_isdst; /*whether daylight saving time is used, positive if used*/│
│} │
└──────────────────────┘
Date storage structure date
┌───────────────┐
│struct date │
│{ │
│ int da_year; /*years since 1900*/│
│ char da_day; /*day*/ │
│ char da_mon; /*month 1=Jan*/ │
│} │
└───────────────┘
Time storage structure time
┌────────────────┐
│struct time │
│{ │
│ unsigned char ti_min; /*minutes*/│
│ unsigned char ti_hour; /*hours*/│
│ unsigned char ti_hund; │
│ unsigned char ti_sec; /*seconds*/ │
│ │
└────────────────┘
char *ctime(long *clock)
this function converts the time pointed to by clock (such as the time returned by function time) into a string in the following format:
Mon Nov 21 11:31:54 1983\n\0
char asctime(struct tm *tm)
this function converts the time in the specified tm structure into a string in the following format:
Mon Nov 21 11:31:54 1983\n\0
double difftime(time_t time2,time_t time1)
calculates the time difference between structures time2 and time1 (in seconds)
struct tm *gmtime(long *clock)
this function converts the time pointed to by clock (such as the time returned by function time) into Greenwich Mean Time and returns it in tm structure form
struct tm *localtime(long *clock)
this function converts the time pointed to by clock (such as the time returned by function time) into local standard time and returns it in tm structure form
void tzset()this function provides compatibility with the UNIX operating system
long dostounix(struct date *dateptr,struct time *timeptr)
this function converts the date pointed to by dateptr and the time pointed to by timeptr into UNIX format, and returns the number of seconds from midnight on January 1, 1970 Greenwich time up to now
void unixtodos(long utime,struct date *dateptr,struct time *timeptr)
this function converts utime, the number of seconds from midnight on January 1, 1970 Greenwich time up to now, into DOS format and stores it in the user-specified structures dateptr and timeptr
void getdate(struct date *dateblk)
this function writes the computer's date into structure dateblk for user use
void setdate(struct date *dateblk)
this function changes the computer's date to the date specified by structure dateblk
void gettime(struct time *timep)
this function writes the computer's time into structure timep for user use
void settime(struct time *timep)
this function changes the computer's time to the time pointed to by structure timep
long time(long *tloc)
this function gives the number of seconds that have elapsed from midnight on January 1, 1970 Greenwich time until now, and stores this value in the unit pointed to by tloc.
int stime(long *tp)this function writes the time pointed to by tp (for example the time returned by time) into the computer.
熟能生巧,巧能生精,一艺不精,终生无成,精亦求精,始有所成,臻于完美,永无止境!
金狮電腦軟體工作室愿竭诚为您服务!
QQ群:8393170(定期清理不发言者)
个人网站:http://www.520269.cn
电子邮件:doujiehui@vip.qq.com
微信公众号: doujiehui
Floor 10 Posted 2004-05-23 00:00 ·  中国 江苏 苏州 昆山市 电信
中级用户
★★
Credits 440
Posts 103
Joined 2004-01-12 00:00
22-year member
UID 15384
Gender Female
Status Offline
Kinglion

You're really amazing~~

Is everything above complete?
Floor 11 Posted 2004-05-25 00:00 ·  中国 辽宁 朝阳 联通
铂金会员
★★★★
痴迷DOS者
Credits 5,798
Posts 1,924
Joined 2003-06-20 00:00
23-year member
UID 5583
Gender Male
From 金獅電腦軟體工作室
Status Offline
There should probably be some more, but mastering the above is enough to use.
熟能生巧,巧能生精,一艺不精,终生无成,精亦求精,始有所成,臻于完美,永无止境!
金狮電腦軟體工作室愿竭诚为您服务!
QQ群:8393170(定期清理不发言者)
个人网站:http://www.520269.cn
电子邮件:doujiehui@vip.qq.com
微信公众号: doujiehui
Floor 12 Posted 2004-05-25 00:00 ·  中国 上海 杨浦区 电信
初级用户
Credits 117
Posts 4
Joined 2004-05-25 00:00
22-year member
UID 25300
Gender Male
Status Offline
With this much already, there should be a few example problems!! There should be some programming examples, right!
Floor 13 Posted 2004-07-14 00:00 ·  中国 湖北 武汉 电信
初级用户
Credits 118
Posts 7
Joined 2004-07-14 00:00
22-year member
UID 28380
Gender Male
From 湖北
Status Offline
Awesome
I seriously admire you!
Forum Jump: