C实例---创建临时文件

代码:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main ()
{
    FILE *temp;
    char c;
    /* FILE *tmpfile() */
    if ( (temp = tmpfile()) != NULL )
        fputs("\nHello World!\nHello ", temp);

    /* void rewind(FILE *fp) */
    rewind(temp);
    while ((c = fgetc(temp)) != EOF)
        printf("%c", c);
    printf("\n");
    fclose(temp);
    return 0;
}

运行结果:
这里写图片描述

猜你喜欢

转载自blog.csdn.net/huazhen1234/article/details/54956555
今日推荐