Skip to content

Instantly share code, notes, and snippets.

@murikadan
Created August 27, 2012 13:35
Show Gist options
  • Save murikadan/3488454 to your computer and use it in GitHub Desktop.
Save murikadan/3488454 to your computer and use it in GitHub Desktop.
Write a string or a number to a file
void writestring(char *);
void writedigit(int);
void writestring(char *s)
{
FILE *fp;
char nl[]="\n";
fp=fopen("output","a");
fprintf(fp,"%s",nl);
fprintf(fp,"%s",s);
fclose(fp);
}
void writedigit(int s)
{
FILE *fp;
char nl[]="\n";
fp=fopen("output","a");
fprintf(fp,"%s",nl);
fprintf(fp,"%d",s);
fclose(fp);
}
@murikadan
Copy link
Author

File is created if not existing, if exists then appended

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment