#include <stdio.h>
int main(void)
{
char buf[64] = "temp file";
FILE *fp = tmpfile();
fputs(buf, fp);
buf[0] = '\0';
printf("buf = %s\n", buf);
rewind(fp);
fgets(buf, 64, fp);
printf("buf = %s\n", buf);
// Temporary file is closed and deleted when the program exits normally
return 0;
}
/*
run:
buf =
buf = temp file
*/