display/init.c
// Read contents of file in string
Read contents of file in string
Read contents of file in string
char *read_file(const char *filename)
{
	FILE *fp = fopen(filename, "r");
	if (fp == NULL) {
		printf("Error opening file %s\n", filename);
		exit(1);
	}
	fseek(fp, 0, SEEK_END);
	long fsize = ftell(fp);
	fseek(fp, 0, SEEK_SET);
	char *string = malloc(fsize + 1);
	fread(string, fsize, 1, fp);
	fclose(fp);
	string[fsize] = 0;
	return string;
}
char * read_file ( const char * filename ) { FILE * fp = fopen ( filename , " " ) ; if ( fp == NULL ) { printf ( " \n " , filename ) ; exit ( 1 ) ; } fseek ( fp , 0 , SEEK_END ) ; long fsize = ftell ( fp ) ; fseek ( fp , 0 , SEEK_SET ) ; char * string = malloc ( fsize + 1 ) ; fread ( string , fsize , 1 , fp ) ; fclose ( fp ) ; string [ fsize ] = 0 ; return string ; }
Read contents of file in string
Read contents of file in string