Skip to content

Instantly share code, notes, and snippets.

@mortymacs
Created August 25, 2024 08:02
Show Gist options
  • Save mortymacs/0b99bfdc7cdc25e2da34bb866cab32c5 to your computer and use it in GitHub Desktop.
Save mortymacs/0b99bfdc7cdc25e2da34bb866cab32c5 to your computer and use it in GitHub Desktop.
Temp file in C
#include <stdio.h>
int main()
{
char b[255];
FILE *f;
f = tmpfile();
fputs("hello mr dj", f);
rewind(f); //rewind to the beginning of the tmp file.
fgets(b, 255, f);
fputs(b, stdout); //or printf("%s\n", b);
fclose(f);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment