Created
June 12, 2014 11:14
-
-
Save morganp/e5d6d1e30cf52b08ebe4 to your computer and use it in GitHub Desktop.
Functions return file pointer main and function split over files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
gcc file_example_main.c file_example.c -o file_example |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
static int Sfile_open=0; | |
FILE *Open_Sfile(char *modname){ | |
char file_name[256]; | |
FILE *Sfile; | |
if (Sfile_open==0) { | |
strcpy(file_name,modname); | |
Sfile=fopen(file_name,"w"); | |
printf("// Writing file %s\n",file_name); | |
Sfile_open=1; | |
}; | |
return Sfile; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
FILE *Open_Sfile(char *); | |
int main(int argc, char **argv) { | |
FILE *source_file; | |
source_file = Open_Sfile("example.txt"); | |
fprintf(source_file, "Helloworld\n"); | |
fclose(source_file); | |
exit(0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment