All pastes #1683459 Raw Edit

clueless

public text v1 · immutable
#1683459 ·published 2009-11-23 09:45 UTC
rendered paste body
#include <stdio.h>#include <stdlib.h>#include <string.h>int main(int argc, char *argv[]){	char *filename = (char*) malloc( (strlen( argv[1]) +1) * sizeof( *filename ) );		strcpy(filename, argv[1]);		FILE *pFile;	pFile = fopen(filename, "r");		//get the file size	long lSize;	char * buffer;	size_t result;		fseek(pFile, 0, SEEK_END);	lSize = ftell( pFile );	rewind( pFile );	//allocate memory for the file	buffer = (char*) malloc( sizeof(char)*lSize);	if(buffer == NULL)	{		printf("Memory error\n");		exit(2);	}		//copy the file into buffer	result = fread (buffer,1,lSize,pFile);	if(result != lSize)	{		printf(" Reading error, check permissions");		exit(3);	}		printf("%s\n", buffer);		//Cleaning up	fclose(pFile);	free(filename);	free(buffer);	exit(EXIT_SUCCESS);	}