|
int _access( const char *path, int mode ); |
| io.h |
| 检查某个文件的存取方式,比如说是只读方式、只写方式等。如果指定的存取方式有效,则函数返回0,否则函数返回-1 |
| 这个例子使用-access函数来检查文件access.c是否是可写的: #include <io.h>
#include <stdio.h>
#include <stdlib.h>
void main( void )
{
if( (_access( "ACCESS.C", 0 )) != -1 )
{ printf( "File ACCESS.C exists\n" );
if( (_access( "ACCESS.C", 2 )) != -1 )
printf( "File ACCESS.C has write permission\n" );
}
} |
|
|
void *_alloca( size_t size ); |
| malloc.h |
| 在堆栈上分配一个内存空间,返回一个指向该内存空间地址的void型指针 |
| 在堆栈上分配一个50字节的内存空间: Int *pointer; size_t Size=100; Pointer=(int *)_alloca(Size); |
|
|
__int64 _atoi64( const char *string ); |
| stdlib.h |
| 把一个字符串转换为_int64型 |
| 和atof函数类似 |
|
|
unsigned long _beginthread( void( __cdecl *start_address )( void * ), unsigned stack_size, void *arglist );
unsigned long _beginthreadex( |
| process.h |
| 创建一个线程 |
| 这个例子显示了_beginthread函数的基本用法,FirstThread是线程的起始地址,数字20是线程的堆栈空间,常量NULL是线程的参数表: _beginthread(FirstThread,20,NULL); |
|
|
unsigned long _beginthreadex( void *security, unsigned stack_size, unsigned ( __stdcall *start_address )( void * ), void *arglist, unsigned initflag, unsigned *thrdaddr ); |
| process.h |
|
|
void _c_exit( void ); |
| process.h |
| 进行清除操作(释放已占用的内存空间等),但是不终止程序 |
| 和_cexit函数类似 |
|
|
double _cabs( struct _complex z ); |
| math.h |
| 计算一个复数的绝对值 |
| 把一个复数ComplexNumber赋给变量d:struct _complex number = { 3.0, 4.0 };
double d; d = _cabs( number ); |
|
|
void _cexit( void ); |
| process.h |
| 进行清除操作(释放已占用的内存空间等),但是不终止程序 |
| 这个例子中如果用户按下y键,则进行清除操作: int button; _cputs("Yes or No?"); button=_getch(); if(toupper(button)=='y') _cexit(); |
|
|
char *_cgets( char *buffer ); |
| conio.h |
| 从键盘得到一个字符串 |
| 数字80用来限制屏幕上每行最多只能输入80个字符: char *string; char Buffer[82]={80}; string=_cgets(Buffer); |
|
|
int _chdir( const char *dirname ); |
| direct.h |
| 改变当前的工作目录,若成功则返回0,否则返回-1, |
| 这个例子中实现了把当前目录改为d:\visual c++: _chdir("d;\\visual c++"); |
|
|
int _chdrive( int drive ); |
| direct.h |
| 改变当前的工作驱动器 |
| 这个例子中实现了检查计算机中有多少个可用的驱动器(PC机最多可以装26个驱动器): int Drive=1; while(Drive<=26) {if(_chdrive(Drive)==0) printf("%c\n",Drive+'A'-1); Drive++;} |
|
|
double _chgsign( double x ); |
| float.h |
| 改变一个double型数的正负号(正变为负,负变为正) |
| 给double型变量x赋值为-12345.678: double x; x=_chgsign(12345.678); |
|
|
int _chmod( const char *filename, int pmode ); |
| io.h |
| 改变文件的读写许可设置,如果改变成功返回0,否则返回-1 |
| 这个例子中实现了把文件sample.txt设置为只读文件: if(_chmod("sample.txt",_S_IREAD)==-1) cout<<"文件sample.txt不存在"; else cout<<"文件sample.txt变为只读文件"; |
|
|
int _chsize( int handle, long size ); |
| io.h |
| 改变文件的字节长度,如果成功返回0,否则返回-1 |
| 和_chmod函数类似 |
|
|
unsigned int _clear87( void ); |
| float.h |
| 返回并且清除浮点状态字 |
| 这个例子中变量x是float型的,把一个double型的值赋给它时可能会引起数据的溢出,这个时候我们使用_clear87函数来检查溢出的情况: float x; double y=1.4e-35; x=y; printf("浮点状态字%x代表数据的溢出\n",_clear87()); |
|
|
unsigned int _clearfp( void ); |
| float.h |
| 返回并且清除浮点状态字 |
| 和_clear87函数类似 |
|
|
int _close( int handle ); |
| io.h |
| 关闭文件,如果成功返回0,否则返回-1 |
| 这个例子中先以只读方式打开文件sample.txt,然后再把它关闭: int Handle; Handle= _open(" c:\\sanmple.txt",_O_RDONLY); if(Handle==-1) perror("出错!"); else {cout<<"文件已经打开"; _close(Handle); } |
|
|
int _commit( int handle ); |
| io.h |
| 把某个文件的数据直接存储到磁盘上,如果成功返回0,否则返回-1 |
| 这个例子中可以把文件的数据在操作中及时写入磁盘,可以避免一些以外情况导致文件的数据丢失: int Handle; if( (Handle=_open("sample.txt",_O_RDWR))!=-1) { ...... _commit(Handle); ...... _close(Handle); |
|
|
unsigned int _control87( unsigned int new, unsigned int mask ); |
| float.h |
| 返回或者设置浮点控制字 |
| _control87函数可以控制浮点类型数据的精度: double Value=0.1; _control87(_PC_24,MCW_PC); printf("24位精度:%f\n",Value); _control87(_CW_DEFAULT,0xFFFFF); printf("缺省精度:%f\n",Value); |
|
|
unsigned int _controlfp( unsigned int new, unsigned int mask ); |
| float.h |
| 返回或者设置浮点控制字 |
| 和_control87函数类似 |
|
|
double _copysign( double x, double y ); |
| float.h |
| 以第二个参数y的符号(正或负)返回第一个参数x |
| 这个例子中变量a的值为-0.4567: double x=0.4567; double y=-0.123; double a; a=_copysign(x,y); |
|
|
int _cprintf( const char *format [, argument] ... ); |
| conio.h |
| 用指定的格式在显示器上输出信息 |
| int I = -16, h = 29; unsigned u = 62511; char c = 'A'; char s[] = "Test";_cprintf( "%d %.4x %u %c %s\r\n", I, h, u, c, s ); |
|
|
int _cputs( const char *string ); |
| conio.h |
| 在显示器上输出一个字符串,若成功则返回0,否则返回一个非0值 |
| 这个例子中实现了在显示器上显示“hello!”: char *p="hello!"; _cputs(p); |
|
|
int _creat( const char *filename, int pmode ); |
| io.h |
| 创建一个新的文件,若成功返回0,否则返回-1 |
| 这个例子中实现了创建一个新文件sample.txt: int Handle; Handle=_creat( "sample.txt",_S_IREAD | _S_IWRITE); |
|
|
int _cscanf( const char *format [, argument] ... ); |
| conio.h |
| 从键盘上输入已经指定格式的数据 |
| 这个例子中%d就是格式控制: int x; _csanf("%d",&x); |
|
|
int _cwait( int *termstat, int procHandle, int action ); |
| process.h |
| 某个进程开始进入等待状态直到另一个进程终止为止 |
| 这个例子中若变量x为2将显示两个carl: struct process{ int id; char name[40]; } process[3]={{0,"ann"},{0,"beth"},{0,"carl"}}; void main(int argc,char *argv[]) { int index,result; if(argc==1) {for (index=0; index<3;index++) process[index].id=_spawnl(_P_NOWAIT,argv[0],argv[0],process[index].name,NULL);index=getrandom(0,2); cout<<procsee[index].name<<endl; _cwait(&result,process[index].id,_WAIT_CHILD); cout<<process[index].name<<endl; |
|
|
int_dup( int handle ); |
| io.h |
| 为一个已经打开的文件建立第二个句柄 |
| 这个例子中给已经有句柄的标准输出设备(stdout)建立第二个句柄Monitor ,然后再恢复原来的句柄: int Monitor; Monitor = _dup(1); ...... _dup2(Monitor,1); |
|
|
int _dup2( int handle1, int handle2 ); |
| io.h |
|
|
char *_ecvt( double value, int count, int *dec, int *sign ); |
| stdlib.h |
| 把一个double型的数据转换为一个字符串 |
| 这个例子中变量Prcision存储数字的精度,变量Decimal存储小数点的位置,变量Sign存储数字的符号: char *String; double Value =2.143554; int Precision =10, Decimal, Sign; String= _ecvt(Value,Precision,&Decimal,&sign); |
|
|
void _endthread( void ); |
| process.h |
| 终止_beginthread函数创建的某个线程 |
| 请参看_beginthread函数 |
|
|
void _endthreadex( unsigned retval ); |
| process.h |
| 终止_beginthread函数创建的某个线程 |
| 和_endthread函数类似 |
|
|
int _eof( int handle ); |
| io.h |
| 测试文件指针是否指向文件尾部,若指向文件尾部返回0,否则返回-1 |
| 这个例子中打开文件eof.c,每次读取10个字节,直到全部字节被读完为止,然后显示文件的长度:void main( void ){
int fh, count, total = 0;
char buf[10]; if( (fh = _open( "eof.c", _O_RDONLY )) == - 1 ) { perror( "Open failed"); exit( 1 );
} while( !_eof( fh ) ) { if( (count = _read( fh, buf, 10 )) == -1 ) {
perror( "Read error" ); break;
} total += count; } printf( "Number of bytes read = %d\n", total );
_close( fh ); |
|
|
int _execl( const char *cmdname, const char *arg0, ... Const char *argn, NULL ); |
| process.h |
| 在父进程中装载并执行新的子进程,若成功则返回0,否则返回-1 |
| 这个例子介绍了以_exec开头的8个函数的用法: char *my_env[] = { "THIS=environment will be", "PASSED=to new process by", "the EXEC=functions",
NULL}; void main() { char *args[4], prog[80];
int ch; printf( "Enter name of program to exec: " ); gets( prog );
printf( " 1. _execl 2. _execle 3. _execlp 4. _execlpe\n" ); printf( " 5. _execv 6. _execve 7. _execvp 8. _execvpe\n" ); printf( "Type a number from 1 to 8 (or 0 to quit): " ); ch = _getche();
if( (ch < '1') || (ch > '8') ) exit( 1 ); printf( "\n\n" ); args[0] = prog; args[1] = "exec??"; args[2] = "two"; args[3] = NULL; switch( ch ) { case '1': _execl( prog, prog, "_execl", "two", NULL ); break; case '2': _execle( prog, prog, "_execle", "two", NULL, my_env ); break; case '3': _execlp( prog, prog, _execlp", "two", NULL ); break; case '4 ': _execlpe( prog, prog, "_execlpe", "two", NULL, my_env ); break; case '5': _execv( prog, args ); break; case '6': _execve( prog, args, my_env ); break; case '7': _execvp( prog, args ); break; case '8': _execvpe( prog, args, my_env ); break; default: break; } printf( "\nProcess was not execed." ); exit( 0 ); } |
|
|
int _execle( const char *cmdname, const char *arg0, ... Const char *argn, NULL, const char *const *envp ); |
| process.h |
| 在父进程中装载并执行新的子进程,若成功则返回0,否则返回-1 |
| 请参看_execl函数 |
|
|
int _execlp( const char *cmdname, const char *arg0, ... Const char *argn, NULL ); |
| process.h |
| 在父进程中装载并执行新的子进程,若成功则返回0,否则返回-1 |
| 请参看_execl函数 |
|
|
int _execlpe( const char *cmdname, const char *arg0, ... Const char *argn, NULL, const char *const *envp ); |
| process.h |
| 在父进程中装载并执行新的子进程,若成功则返回0,否则返回-1 |
| 请参看_execl函数 |
|
|
int _execv( const char *cmdname, const char *const *argv ); |
| process.h |
| 在父进程中装载并执行新的子进程,若成功则返回0,否则返回-1 |
| 请参看_execl函数 |
|
|
int _execve( const char *cmdname, const char *const *argv, const char *const *envp ); |
| process.h |
| 在父进程中装载并执行新的子进程,若成功则返回0,否则返回-1 |
| 请参看_execl函数 |
|
|
int _execvp( const char *cmdname, const char *const *argv ); |
| process.h |
| 在父进程中装载并执行新的子进程,若成功则返回0,否则返回-1 |
| 请参看_execl函数 |
|
|
int _execvpe( const char *cmdname, const char *const *argv, const char *const *envp ); |
| process.h |
| 在父进程中装载并执行新的子进程,若成功则返回0,否则返回-1 |
| 请参看_execl函数 |
|
|
void _exit( int status ); |
process.h stdlib.h |
| 进行清除操作(释放已占用的内存空间等),并且终止当前进程 |
| 和exit函数类似 |
|
|
void *_expand( void *memblock, size_t size ); |
| malloc.h |
| 改变某个内存区域的字节数 |
| 这个例子中把buffer从512个字节扩展到了1024个字节: char *buffer; buffer=(char *)calloc(512,sizeof(char)); cout<<"内存区域为512个字节!"<<endl; buffer=(char *)_expand(buffer,1024); cout<<"内存区域为1024个字节!"; free(buffer); |
|
|
int _fcloseall( void ); |
| stdio.h |
| 关闭已经打开的所有数据流,若成功则返回被关闭的数据流的个数,否则返回eof |
| 和fclose函数类似 |
|
|
char *_fcvt( double value, int count, int *dec, int *sign ); |
| stdlib.h |
| 把一个double型的数据转换为一个字符串 |
| 和_ecvt函数类似 |
|
|
FILE *_fdopen( int handle, const char *mode ); |
| stdio.h |
| 把一个以低级I/O方式打开的文件与某个数据流联系起来,即将这个文件“数据流化”,若成功则返回一个指向该数据流的指针,否则返回NULL |
| 这个例子中先以句柄方式打开文件sample.txt,然后以数据流的方式处理该文件: int handle,line=0; FILE *stream; char buffer[120]; handle=_open("sample.txt",_O_RDONLY); steam=_fdopen(handle,"r"); while(fgets(buffer,120,stream)!=NULL) line++; fclose(stream); cout<<"文件中有"<<line<<"行文字"; |
|
|
int _fgetchar( void ); |
| stdio.h |
| 从标准输入设备上读取一个字符 |
| 和fgetc函数类似 |
|
|
wint_t _fgetwchar( void ); |
stdio.h wchar.h |
| 从标准输入设备读取一个字符 |
| 和fgetchar类似 |
|
|
long _filelength( int handle ); |
| io.h |
| 测试文件的字节长度,若失败返回-1L |
| 这个例子中显示了文件sample.txt的字节长度: int Handle; if(Handle=_open("sample.txt",_O_RDWR)!=-1) { cout<<"文件长度是"<<_filelength(Handle)<<"字节"; _close(Handle); } |
|
|
__int64 _filelengthi64( int handle ); |
| io.h |
| 测试文件的字节长度,若失败返回-1L |
| 和_filelength函数类似 |
|
|
int _fileno( FILE *stream ); |
| stdio.h |
| 得到某个数据流的文件句柄 |
| 这个例子中显示了标准输出设备stdout的文件句柄: cout<<"标准输出设备sdtout的文件句柄:"<<_fileno(stdout)<<endl; |
|
|
int _findclose( long handle ); |
| io.h |
| 关闭已经打开的搜索句柄,释放相关的资源,若成功则返回0,否则返回-1 |
| 请参看_findfirst函数 |
|
|
long _findfirst( char *filespec, struct _finddata_t *fileinfo ); |
| io.h |
| 搜索与指定的文件名称匹配的第一个实例,若成功则返回第一个实例的句柄,否则返回-1L |
| 这个例子中实现了搜索当前目录中所有的文本文件(.txt),并且显示出它的名字: long Handle; struct_finddata_t FileInfo; if((Handle=_findfirst("*.txt",&FileInfo))==-1L) cout<<"没有找到匹配的项目"; else { cout<<FileInfo.name<<endl; while( _findnext(Handle,&FileInfo)==0) cout<<FileInfo.name<<endl; _findclose(Handle); } |
|
|
__int64 _findfirsti64( char *filespec, struct _finddata_t *fileinfo ); |
| io.h |
| 搜索与指定的文件名称匹配的第一个实例,若成功则返回第一个实例的句柄,否则返回-1L |
| 和_findfirst函数类似 |
|
|
int _findnext( long handle, struct _finddata_t *fileinfo ); |
| io.h |
| 搜索与_findfirst函数提供的文件名称匹配的下一个实例,若成功则返回0,否则返回-1 |
| 请参看_findfirst函数 |
|
|
__int64 _findnexti64( long handle, struct _finddata_t *fileinfo ); |
| io.h |
| 搜索与_findfirst64函数提供的文件名称匹配的下一个实例,若成功则返回0,否则返回-1 |
| 和_findnext函数类似 |
|
|
int _finite( double x ); |
| float.h |
| 确定double型参数x是否为有尽小数,若是则返回一个非0值,否则返回0 |
| 这个例子测试了double型变量x是否为有尽小数: double x; x=0.39348745497854; if(_finite(x)!=0) cout<<"变量x是有尽小数"; |
|
|
int _flushall( void ); |
| stdio.h |
| 清除所有的数据流和所有的缓冲区 |
| 这个例子中将清除所有的数据流和缓冲区: int Count; Count= _flushall(); |
|
|
int _fpclass( doublex ); |
| stdio.h |
| 返回一个状态字来记录参数x的浮点类信息 |
| double x=5.00000; if(_fpclass(x)==_FPCLASS_PN) cout<<"x是正数"; |
|
|
int _fpieee_flt( unsigned long exc_code, struct _EXCEPTION_POINTERS *exc_info, int handler(_FPIEEE_RECORD *) ); |
| fpieee.h |
| 当发生IEEE浮点异常时,引发用户定义的错误处理程序,返回的值即为错误处理程序的返回值 |
| 这个例子是各种浮点异常的错误处理程序的框架: #define _EXE_MASK_EM_UNDERFLOW +\_EM_OVERFLOW+\_EM_ZERODIVIDE+\_EM_INEXACT void main() { __try {_controlfp(_EXC_MASK,_MCW_EM); __except(_fpieee_flt(GetExceptionCode(),GetExecptionInformation(),fpieee_Handler)) { …} int fpieee_Handler(_FPIEEE_RECORD *pIEEE) { if ((pIEEE->Cause.InvalidOperation)&&(pIEEE->Result.Format==_FpFormatFp32)) { pIEEE->Result.Value.Fp32Value=0.0F; return EXCEPTION_CONTINUE_EXECUTION;} else return EXECEPTION_EXECUTE_HANDLER;} |
|
|
void _fpreset( void ); |
| float.h |
| 初始化浮点算术程序包 |
| 这个例子中signal函数捕捉到浮点错误信号,然后调用_fpreset和longjmp函数: jmp_buf jumpmark; int fperr; void main() { int jumpteturn; _control87(0,_MCW_EM); if(signal(SIGFPE,Fphandler)==SIG_ERR) {fprintf(stderr,"出错"); abort(); } jumpreturn=setjmp(jumpmark); if(jumpreturn==0) {…}} void FPHandle(int signal,int code) {fperr=code; _fpreset(); longjmp(jumpmark,-1);} |
|
|
int _fputchar( int c ); |
| stdio.h |
| 把一个字符写入标准输出设备,若成功则返回写入的字符数,否则返回EOF |
| 和fputc函数类似 |
|
|
wint_t _fputwchar( wint_t c ); |
stdio.h wchar.h |
| 把一个字符写入标准输出设备,若成功则返回写入的字符数,否则返回WEOF |
| 和fputchar函数类似 |
|
|
FILE *_fsopen( const char *filename, const char *mode, int shflag ); |
| stdio.h |
| 以共享的方式打开一个数据流 |
| FILE *Stream; if( (stream = _fsopen( "outfile", "wt", _SH_DENYWR )) != NULL ) fprintf( stream, "No one else in the network can write to this file until we are done.\n" ); fclose( stream ); { |
|
|
int _fstat( int handle, struct _stat *buffer ); |
sys/stat.h sys/types.h |
| 返回一个已经打开的文件的状态信息,若成功则返回0,否则返回-1 |
| 这个例子中创建了一个文件sample.txt,并写入了一个字符串: int handle,result; char string[]="hello"; struct_stat status; handle=_open("sample.txt",_O_CREST|_O_WRONLY); result=_fstat(handle,&status); _close(handle);} |
|
|
__int64 _fstati64( int handle, struct _stat *buffer ); |
sys/stat.h sys/types.h |
| 返回一个已经打开的文件的状态信息,若成功则返回0,否则返回-1 |
| 和_fstat函数类似 |
|
|
void _ftime( struct _timeb *timeptr ); |
sys/types.h sys/timeb.h |
| 返回当前时间 |
| 这个例子中把当前时间的信息写入结构timebuffer中: struct_time timebuffer; char *p; _ftime(&timebuffer); p=ctime(&(timebuffer.time)); |
|
|
char *_fullpath( char *absPath, const char *relPath, size_t maxLength ); |
| stdlib.h |
| 把某个相对路径转换为完整路径(绝对路径),若成功则返回一个指向该路径的指针,否则返回NULL |
| 这个例子中实现了把用户输入的相对路径转换为完整路径: char PartPath[_MAX_PATH], FullPATH[_MAX_PARH]; cout<<"请输入相对路径:"; gets(PartPath); if( _fullpath(FullPath,PartPath,_MAX_PARH)!=NULL) cout<<"绝对路径为:"<<FullPath<<endl; |
|
|
int _futime( int handle, struct _utimbuf *filetime ); |
| sys/utime.h |
| 为某个已经打开的文件设置修改时间,若成功则返回0,否则返回-1 |
| 这个例子中使用了_futime函数来把当前的系统时间设置为文件修改的时间: int hFile; system("dir futime.c"); hFile=_open("futime.c",_o_RDWR); if( _futime(hFile,NULL)==-1) perror("_futime failed\n"); else printf( "File time modified\n"); close (hfile); system("dir futime.c"); |
|
|
char *_gcvt( double value, int digits, char *buffer ); |
| stdlib.h |
| 把一个double型的数据转换成一个字符串,并且把该字符串存储在缓冲区中,若成功则返回一个指向字符串的指针 |
| 这个例子中把一个double型数据-3.1415e5转换成7位的字符串: char Buffer[50]; double source = -3.1415e5; _gcvt( source, 7, Buffer ); printf( "source: %f Buffer: '%s'\n", source, Buffer ); |
|
|
long _get_osfhandle( int filehandle ); |
| io.h |
| 返回某个数据流的FILE指针所对应的操作系统文件句柄,若失败则返回-1 |
| 这个例子中返回了指针Handle所对应的操作系统文件句柄OSFileHandle: FILE *Handle; long OSFlieHandle; OSFileHandle=_get_osfhandle(Handle); |
|
|
size_t _get_sbh_threshold( void ); |
| malloc.h |
| 返回小块的上限值,缺省为480 |
| 这个例子中显示了小块堆的上限值: size_t limit; limit=_get_sbh_threshold; |
|
|
int _getch( void ); |
| conio.h |
| 从键盘读取一个字符,但不把它回显 |
| 这个例子中实现了从键盘输入20个字符: char Buffer[25]; int Count; for(Count=1;Count<=20;Count++) { Buffer[Count]=_getch(); } |
|
|
int _getche( void ); |
| conio.h |
| 从键盘读取一个字符,并且把它回显 |
| 和_getch函数类似 |
|
|
char *_getcwd( char *buffer, int maxlen ); |
| direct.h |
| 返回当前的工作目录 |
| 这个例子中显示了当前的工作目录: char Directory[_MAX_PATH]; if(_getcwd(Directory,_MAX_PATH)!=NULL) cout<<"当前的工作目录是:"<<Directory; |
|
|
char *_getdcwd( int drive, char *buffer, int maxlen ); |
| direct.h |
| 返回指定的驱动器上当前工作目录的完整路径(绝对路径) |
| 这个例子中显示了c盘的当前工作目录的名称(A盘为1,B盘为2,C盘为3,依次类推): int Drive=3; cahr Directory=[_MAX_PATH]; if (Drive,Directory,_MAX_PATH)!=NULL) cout<<"c盘的当前工作目录的完整路径为:"<<Directory; |
|
|
int _getdrive( void ); |
| direct.h |
| 返回当前的磁盘驱动器,1代表A盘,2代表B盘,依次类推 |
| int _getdrive( void ); |
|
|
int _getmbcp( void ); |
| mbctype.h |
| 返回当前正在使用的多字节代码页,若返回值为0,则表示当前使用的是单字节代码,否则为多字节代码 |
| 这个例子中可以判断当前的代码页的类型: if(_getmbcp()!=0) cout<<"正在使用多字节代码页"<<endl; else cout<<"正在使用单代码页"<<endl; |
|
|
int _getpid( void ); |
| process.h |
| 返回进程识别代码 |
| 这个例子中可以显示当前进程的识别代码: printf( "\nProcess id: %d\n", _getpid() ); |
|
|
int _getw( FILE *stream ); |
| stdio.h |
| 从某个数据流中读取一个整型数据 |
| 这个例子中从文件sample.txt中读取了一个整数: FILE *Stream; int x; Stream=fopen("sample.txt","rb"); I=_getw(Stream); cout<<I; fclose(Stream); |
|
|
wchar_t *_getws( wchar_t *buffer ); |
stdio.h wchar.h |
| 从标准输入设备上读取一行宽字符 |
| 和gets函数类似 |
|
|
int _heapadd( void *memblock, size_t size ); |
| malloc.h |
| 把一个内存区域添加到堆中去 |
| 这个例子中把一个假设长度为20字节的区域添加到堆中,指针Buffer指向这个区域: _heapadd(Buffer,20); |
|
|
int _heapchk( void ); |
| malloc.h |
| 检查堆的连续性,若成功则返回一组预定义常量中的一个,否则把全局变量errno设置为ENOSYS |
| 这个例子中先分配然后释放一块内存区域Buffer来检查堆的状态是否正常: int heapstatus; char *buffer; if( (buffer = (char *)malloc( 100 )) != NULL ) free( buffer );heapstatus = _heapchk(); switch( heapstatus ) { case _HEAPOK: printf(" OK - heap is fine\n" );
break;
case _HEAPEMPTY:
printf(" OK - heap is empty\n" );
break;
case _HEAPBADBEGIN:
printf( "ERROR - bad start of heap\n" );
break;
case _HEAPBADNODE:
printf( "ERROR - bad node in heap\n" );
break;
}
} |
|
|
int _heapmin( void ); |
| malloc.h |
| 释放没有使用的堆空间,返还给操作系统,若成功则返回0,否则返回-1 |
| 本函数多用于进行了堆操作之后用来释放未使用的空间: _heapmin(); |
|
|
int _heapset( unsigned int fill ); |
| malloc.h |
| 检查堆的最小连续性,并且用指定的数值或者字符填充堆的自由项目,若成功则返回一组预定义常量中的一个,否则把全局变量errno设置为ENOSYS |
| 这个例子中使用字符x填充堆中自由项目的每一个字节: char *Buffer; int Status; Buffer=(char *)malloc(100)!=NULL); if((Stream=_heapset('x'))=_HEAPOK) cout<<"成功"; free(Buffer); |
|
|
int _heapwalk( _HEAPINFO *entryinfo ); |
| malloc.h |
| 从头到尾扫描堆,并且返回堆中下一个项目的信息,若成功则返回一组预定义常量中的一个,否则把全局变量errno设置为ENOSYS |
| 这个例子中显示了堆中的每个项目信息: _HEAPINFO x; int status; x._pentry=NULL; while((status=_heapwalk(&x)==_HEAPOK) {cout<<(x._useflag==_USEDENTRY?"已使用":"未使用"); cout<<x._pentry; cout<<x._size ; } |
|
|
double _hypot( double x, double y ); |
| math.h |
| 计算直角三角形的斜边长度,若操作失败则返回无穷大 |
| 这个例子中已知直角三角形的两条直角边的长度,使用函数_hypot可以计算出斜边的长度: double x=3.0,y=4.0; z=_hypot(x,y); |
|
|
char *_i64toa( __int64 value, char *string, int radix ); |
| stdlib.h |
| 把一个__int64型的数据转换为字符串,返回一个指向该宽字符串的指针 |
| 和_itoa函数类似 |
|
|
wchar_t * _i64tow( __int64 value, wchar_t *string, int radix ); |
| stdlib.h |
| 把一个__int64型的数据转换为宽字符串,返回一个指向该宽字符串的指针 |
| 和_itoa函数类似 |
|
|
int _inp( unsigned short port ); |
| conio.h |
| 从端口输入一个字节 |
| 这个例子中实现了从8号端口输入一个字节: int Port=8; int Byte; Byte=_inp(Port); |
|
|
unsigned long _inpd( unsigned short port ); |
| conio.h |
|
|
unsigned short _inpw( unsigned short port ); |
| conio.h |
|
|
int __isascii( int c ); |
| ctype.h |
| 若参数c是一个ASCII 字符(0x00-0x7f),则返回一个非0值,否则返回0 |
| 和isalnum函数类似 |
|
|
int _isatty( int handle ); |
| io.h |
| 若某个句柄和某个字符设备(比如显示器、打印机、终端等)相关联,则返回一个非0值,否则返回0 |
| 这个例子中实现了检查标准输出设备(stdout)是否被重定向到某个磁盘文件: if( _isatty( _fileno( stdout ) ) ) printf( "stdout has not been redirected to a file\n" ); else printf( "stdout has been redirected to a file\n"); |
|
|
int __iscsym( int c ); |
| ctype.h |
| 若参数c是一个字母、数字或者下划线,则返回一个非0值,否则返回0 |
| 和isalnum函数类似 |
|
|
int __iscsymf( int c ); |
| ctype.h |
| 若参数c是一个字母或者下划线,则返回一个非0值,否则返回0 |
| 和isalnum函数类似 |
|
|
int _ismbbalnum( unsigned int c ); |
| mbctype.h |
| 若参数c是一个字母或者一个数字,则返回一个非0值,否则返回0。本函数只适用于多字节字符的代码页 |
| 和isalnum函数类似 |
|
|
int _ismbbalpha( unsigned int c ); |
| mbctype.h |
| 若参数c是一个字母,则返回一个非0值,否返回0。本函数只适用于多字节字符的代码页 |
| 和isalnum函数类似 |
|
|
int _ismbbgraph ( unsigned int c ); |
| mbctype.h |
| 若参数是一个可打印字符(不包括空格),则返回一个非0值,否则返回0。本函数只适用于多字节字符的代码页 |
| 和isalnum函数类似 |
|
|
int _ismbbkalnum( unsigned int c ); |
| mbctype.h |
| 若参数c是一个非ASCII文本符号(标点符号除外),则返回一个非0值,否则返回0。本函数只适用于多字节字符的代码页,通常用于日文编程 |
| 和isalnum函数类似 |
|
|
int _ismbbkana( unsigned int c ); |
| mbctype.h |
| 若参数c是一个日文片假名,则返回一个非0值,否则返回0。本函数只适用于多字节字符的代码页,通常用于日文编程 |
| 和isalnum函数类似 |
|
|
int _ismbbkprint( unsigned int c ); |
| mbctype.h |
| 若参数c是一个非ASCII 文本符号或者非ASCII 标点符号,则返回一个非0值,否则返回0。本函数只适用于多字节字符的代码页,通常用于日文编程 |
| 和isalnum函数类似 |
|
|
int _ismbbkpunct( unsigned int c ); |
| mbctype.h |
| 若参数c是一个非ASCII 标点符号,则返回一个非0值,否则返回0。本函数只适用于多字节字符的代码页,通常用于日文编程 |
| 和isalnum函数类似 |
|
|
int _ismbblead( unsigned int c ); |
mbctype.h mbstring.h |
| 若参数c是某个多字节字符的第一个字节,则返回一个非0值,否则返回0。本函数只适用于多字节字符的代码页 |
| 和isalnum函数类似 |
|
|
int _ismbbprint( unsigned int c ); |
| mbctype.h |
| 若参数c是一个非ASCII的可打印字符,则返回一个非0值,否则返回0。本函数只适用于多字节字符的代码页 |
| 和isalnum函数类似 |
|
|
int _ismbbpunct( unsigned int c ); |
| mbctype.h |
| 若参数c是一个非ASCII 标点符号,则返回一个非0值,否则返回0。本函数只适用于多字节字符的代码页 |
| 和isalnum函数类似 |
|
|
int _ismbbtrail( unsigned int c ); |
mbctype.h mbstring.h |
| 若参数c是某个多字节字符的第二个字符,则返回一个非0值,否则返回0。本函数只适用于多字节字符的代码页 |
| 和isalnum函数类似 |
|
|
int _ismbcalnum( unsigned int c ); |
| mbstring.h |
| 在932代码页环境下,若参数c代表一个单字节的英文字母,则返回一个非0值,否则返回0。本函数只适用于多字节字符的代码页,通常用于日文编程 |
| 和isalnum函数类似 |
|
|
int _ismbcalpha( unsigned int c ); |
| mbstring.h |
| 在932代码页环境下,若参数c代表一个单字节的英文字母或日文片假名,则返回一个非0值,否则返回0。本函数只适用于多字节字符的代码页,通常用于日文编程 |
| 和isalnum函数类似 |
|
|
int _ismbcdigit( unsigned int c ); |
| mbstring.h |
| 在932代码页环境下,若参数c代表一个单字节的ASCII数字字符,则返回一个非0值,否则返回0。本函数只适用于多字节字符的代码页,通常用于日文编程 |
| 和isalnum函数类似 |
|
|
int _ismbcgraph( unsigned int c ); |
| mbstring.h |
| 在932代码页环境下,若参数c代表一个单字节的可打印的ASCII字符或日文片假名(空格除外),则返回一个非0值,否则返回0。本函数只适用于多字节字符的代码页,通常用于日文编程 |
| 和isalnum函数类似 |
|
|
int _ismbchira( unsigned int c ); |
| mbstring.h |
| 在932代码页环境下,若参数c代表一个双字节的日文平假名(0x829F-0x82F1),则返回一个非0值,否则返回0。本函数只适用于多字节字符的代码页,通常用于日文编程 |
| 和isalnum函数类似 |
|
|
int _ismbckata( unsigned int c ); |
| mbstring.h |
| 在932代码页环境下,若参数c代表一个双字节的日文片假名(0x8340-0x8396),则返回一个非0值,否则返回0。本函数只适用于多字节字符的代码页,通常用于日文编程 |
| 和isalnum函数类似 |
|
|
int _ismbcl0( unsigned int c ); |
| mbstring.h |
| 在932代码页环境下,若参数c代表一个JIS(日本工业标准)编码中的非汉字字符(0x8140-0x889E),则返回一个非0值,否则返回0。本函数只适用于多字节字符的代码页,通常用于日文编程 |
| 和isalnum函数类似 |
|
|
int _ismbcl1( unsigned int c ); |
| mbstring.h |
| 在932代码页环境下,若参数c代表一个JIS(日本工业标准)编码中的第一级字符(0x889F-0x9872),则返回一个非0值,否则返回0。本函数只适用于多字节字符的代码页,通常用于日文编程 |
| 和isalnum函数类似 |
|
|
int _ismbcl2( unsigned int c ); |
| mbstring.h |
| 在932代码页环境下,若参数c代表一个JIS(日本工业标准)编码中的第二级字符(0x989F-0xEA9E),则返回一个非0值,否则返回0。本函数只适用于多字节字符的代码页,通常用于日文编程 |
| 和isalnum函数类似 |
|
|
int _ismbclegal( unsigned int c ); |
| mbstring.h |
| 在932代码页环境下,若参数c的第一个字节的数值位于0x81-0x9F或0xE0-0xFC之间,第二个字节的数值位于0x40-0x7E或0x80-0xFC之间,则返回一个非0值,否则返回0。本函数只适用于多字节字符的代码页,通常用于日文编程 |
| 和isalnum函数类似 |
|
|
int _ismbclower( unsigned int c ); |
| mbstring.h |
| 在932代码页环境下,若参数c代表一个单字节的ASCII小写英文字母,则返回一个非0值,否则返回0。本函数只适用于多字节字符的代码页,通常用于日文编程 |
| 和isalnum函数类似 |
|
|
int _ismbcprint( unsigned int c ); |
| mbstring.h |
| 在932代码页环境下,若参数c代表一个单字节的可打印的ASCII字符或日文片假名(包括空格),则返回一个非0值,否则返回0。本函数只适用于多字节字符的代码页,通常用于日文编程 |
| 和isalnum函数类似 |
|
|
int _ismbcpunct( unsigned int c ); |
| mbstring.h |
| 在932代码页环境下,若参数c代表一个单字节的ASCII 标点符号或日文片假名标点符号,则返回一个非0值,否则返回0。本函数只适用于多字节字符的代码页,通常用于日文编程 |
| 和isalnum函数类似 |
|
|
int _ismbcspace( unsigned int c ); |
| mbstring.h |
| 在932代码页环境下,若参数c代表一个单字节的空格字符,则返回一个非0值,否则返回0。本函数只适用于多字节字符的代码页,通常用于日文编程 |
| 和isalnum函数类似 |
|
|
int _ismbcsymbol( unsigned int c ); |
| mbstring.h |
| 在932代码页环境下,若参数c的数值位于0x8141-0x81AC之间,则返回一个非0值,否则返回0。本函数只适用于多字节字符的代码页,通常用于日文编程 |
| 和isalnum函数类似 |
|
|
int _ismbcupper( unsigned int c ); |
| mbstring.h |
| 在932代码页环境下,若参数c代表一个单字节的ASCII大写英文字母,则返回一个非0值,否则返回0。本函数只适用于多字节字符的代码页,通常用于日文编程 |
| 和isalnum函数类似 |
|
|
int _ismbslead( const unsigned char *string, const unsigned char *current ); |
mbctype.h mbstring.h |
| 在一个由多字节字符组成的字符串string中,若指针current指向某个字符的第一个字节,则返回-1,否则返回0。本函数只适用于多字节字符的代码页 |
| 和isalnum函数类似 |
|
|
int _ismbstrail( const unsigned char *string, const unsigned char *current ); |
mbctype.h mbstring.h |
| 在一个由多字节字符组成的字符串string中,若指针current指向某个字符的第二个字节,则返回-1,否则返回0。本函数只适用于多字节字符的代码页 |
| 和isalnum函数类似 |
|
|
int _isnan( double x ); |
| float.h |
| 若参数x是一个NaN,则返回一个非0值 |
| 和isalnum函数类似 |
|
|
char *_itoa( int value, char *string, int radix ); |
| stdlib.h |
| 把一个int型的数据转换为字符串,返回一个指向该字符串的指针 |
| 这个例子中把数字765转换为字符串“765”: int x=765; char y[15]; _itoa(x,y,10); cout<<y; |
|
|
wchar_t * _itow( int value, wchar_t *string, int radix ); |
| stdlib.h |
| 把一个int型的数据转换为宽字符串,返回一个指向该宽字符串的指针 |
| 和_itoa函数类似 |
|
|
int _kbhit( void ); |
| conio.h |
| 检查当前是否有键盘输入,若有则返回一个非0值,否则返回0 |
| 这个例子中屏幕上不停地显示“请按任意键”,如果用户按下键盘的任何一个键就可以使显示停止: while(!_kbhit()) _cputs("请按任意键"); |
|
|
void *_lfind( const void *key, const void *base, unsigned int *num, unsigned int width, int (__cdecl *compare)(const void *elem1, const void *elem2) ); |
| search.h |
| 对指定的关键字进行线形搜索,若成功则返回一个指向搜索到的数组元素的指针 |
| 这个例子中以“hello”为关键字进行搜索: char **result; char *key = "hello"; result = (char **)_lfind( &key, argv, &argc, sizeof(char *), compare ); if( result ) printf( "%s found\n", *result ); else printf( "hello not found!\n" ); |
|
|
int _locking( int handle, int mode, long nbytes ); |
io.h sys/locking.h |
| 锁定或解除一个文件的字节数,若成功则返回0,否则返回-1 |
| 这个例子中把文件sample.txt的前100个字节锁定,然后解除锁定: int handle; handle=_sopen("sample.txt",_O_RDWR,_SH_DENYNO,_S_IREAD|_S_IWRITE); _locking(handle,LK_NBLCK,100L);//锁定 _locking(handle,LK_UNLCK,100L);//解除锁定 |
|
|
double _logb( double x ); |
| float.h |
|