Created
November 2, 2012 20:50
-
-
Save AlexFrazer/4004228 to your computer and use it in GitHub Desktop.
file reader
This file contains 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
/* | |
* reads files | |
* @Alex "Crowz" Frazer | |
*/ | |
#include <stdio.h> | |
#include <string.h> | |
#define OK 0 | |
#define FILE_NOT_FOUND -1 | |
FILE *file; | |
int main() { | |
} | |
char * asciiread(char *filename) { | |
char * contents; | |
file=fopen(filename); | |
if(filename==NULL) { | |
printf("error: file not found"); | |
return FILE_NOT_FOUND; | |
} | |
fseek(file, 0L, SEEK_END); | |
int size=ftell(file); | |
fseek(file, 0L, SEEK_SET); | |
contents=(char *)malloc(size*sizeof(char)); | |
return contents; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment