|
Turbo C 2.0、Borland C++库函数及用例(31) /* get the comspec environment parameter */ flags=fnsplit(s,drive,dir,file,ext); printf("Command processor info:\n"); if(flags & DRIVE) printf("\tdrive: %s\n",drive); if(flags & DIRECTORY) printf("\tdirectory: %s\n",dir); if(flags & FILENAME) printf("\tfile: %s\n",file); if(flags & EXTENSION) printf("\textension: %s\n",ext); return 0; } 函数名: fprintf 功 能: 传送格式化输出到一个流中 用 法: int fprintf( FILE *stream, char *format[, argument,...] ); 程序例:/* Program to create backup of the AUTOEXEC.BAT file */#include <stdio.h>int main(void) { FILE *in, *out; if ((in = fopen("\\AUTOEXEC.BAT", "rt")) == NULL) { fprintf(stderr, "Cannot open input \ file.\n"); return 1; } if ((out = fopen("\\AUTOEXEC.BAK", "wt")) == NULL) { fprintf(stderr, "Cannot open output \ file.\n"); return 1; } while (!feof(in)) fputc(fgetc(in), out); fclose(in); fclose(out); return 0; } 函数名: FP_OFF 功 能: 获取远地址偏移量 用 法: unsigned FP_OFF(void far *farptr); 程序例:/* FP_OFF */#include <dos.h> #include <stdio.h>int main(void) { char *str = "fpoff.c"; printf("The offset of this file in memory\ is: %Fp\n", FP_OFF(str)); return 0; } 函数名: FP_SEG 功 能: 获取远地址段值 用 法: unsigned FP_SEG(void far *farptr); 程序例:/* FP_SEG */#include <dos.h> #include <stdio.h>int main(void) { char *filename = "fpseg.c"; printf("The offset of this file in memory\ is: %Fp\n", FP_SEG(filename)); return(0); } 函数名: fputc 功 能: 送一个字符到一个流中 用 法: int fputc(int ch, FILE *stream); 程序例: #include <stdio.h>int main(void) { char msg[] = "Hello world"; int i = 0; while (msg[i]) { fputc(msg[i], stdout); i++; } return 0; } 函数名: fputchar
|