函数名: vfprintf

功能: 送格式化输出到一流中

用法: int vfprintf(FILE *stream, char *format, va_list param);

程序例:

#include

#include

#include

FILE *fp;

int vfpf(char *fmt, ...)

{

va_list argptr;

int cnt;

va_start(argptr, fmt);

cnt=vfprintf(fp, fmt, argptr);

va_end(argptr);

return(cnt);

}

int main(void)

{

int inumber=30;

float fnumber=90.0;

char string[4]="abc";

fp=tmpfile();

if (fp== NULL)

{

perror("tmpfile() call");

exit(1);

}

vfpf("%d %f %s", inumber, fnumber, string);

rewind(fp);

fscanf(fp,"%d %f %s", &inumber, &fnumber, string);

printf("%d %f %s\n", inumber, fnumber, string);

fclose(fp);

return 0;

}

函数名: vfscanf

功能: 从流中执行格式化输入

用法: int vfscanf(FILE *stream, char *format, va_list param);

程序例:

#include

#include

#include

FILE *fp;

int vfsf(char *fmt, ...)

{

va_list argptr;

int cnt;

va_start(argptr, fmt);

cnt=vfscanf(fp, fmt, argptr);

va_end(argptr);

return(cnt);

}

int main(void)

{

int inumber=30;

float fnumber=90.0;

char string[4]="abc";

fp=tmpfile();

if (fp== NULL)

{

perror("tmpfile() call");

exit(1);

}

fprintf(fp,"%d %f %s\n",inumber,fnumber,string);

rewind(fp);

vfsf("%d %f %s",&inumber,&fnumber,string);

printf("%d %f %s\n",inumber,fnumber,string);

fclose(fp);

return 0;

}