file_get_contents()

Posted by sphinx on February 12, 2008.

/* file_get_contents() function in C - PHP Equivalent by sphinx */

// need filesize() function

char *file_get_contents(char *file) { char *tmp; long long int size; FILE *fp; size = filesize(file); tmp = malloc(size + 1); fp = fopen(file, “rb”); if(fp) { fread(tmp, 1, size, fp); } else { return 0; } fclose(fp); return (char *)tmp; }

Bookmark this article!

BlogLinesDel.icio.usDiggFacebookFurlGoogleRedditSlashDotSphinnSpurl

SquidooStumbleUponTechnoratiYahoo

Make a Comment

Make A Comment: ( None so far )

blockquote and a tags work here.

Liked it here?
Why not try sites on the blogroll...

Get a Free Blog @ plinplan.net