Ok I'm only new to C language, and I've built a program that takes a file and computes the MD5 checksum for it. It works which is a great sign but thats not what I'm considered about. It's the issue of pointers being passed into a function, I'm still trying to get my head around the concept of pointers themselves.

Please can someone run through my code and see that its all in good practice, or even show me a better more efficient way of using them within a function.

Thanks in advance for all your advice.

md5file.h
Code:
/*!
 *	@file		md5file.h
 *	@breif		Computes the MD5 check sum of a given file.
 *
 *	@author		Christopher Turner <[email protected]>
 *	@version	1.0
 *	@date		May 20th, 2010
 */

#define FILE_READ_BUFFER_SIZE 4096 /* 4kb */

/*!
 *	@fn			extern void md5_file(const char *file, const unsigned char *digest)
 *	@brief		Copies the checksum of a file into the given digest variable.
 *
 *	@param[in]	file The path to the file to compute md5 check sum.
 *	@param[out]	digest The variable in which to copy the computed digest to.
 *	@return		Returns 1 if success and 0 if error.
 */
extern int md5_file (const char *file, char *digest);
md5file.c
Code:
#include "md5file.h"

#include <stdio.h>
#include <openssl/md5.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

int md5_file (const char *file, char *digest) {
	
	MD5_CTX md5_struct;
	unsigned char result[MD5_DIGEST_LENGTH];
	char tmp_hex[3];
	int file_d;
	int i;
	char buffer[FILE_READ_BUFFER_SIZE];
	ssize_t bytes_read;
	
	/* Initialize the md5 structure */
	if ( MD5_Init(&md5_struct) == 0 )
		return (0);
	
	/* Open the file */
	file_d = open(file, O_RDONLY);
	
	if ( file_d < 0 )
		return (0);
	
	/* Read the files data */
	while (1) {
		bytes_read = read(file_d, buffer, sizeof(buffer));
		
		if ( bytes_read == 0 )
			break; /* Finished reading file */
		
		if ( bytes_read < 0 )
			return (0); /* File read error */
		
		if ( MD5_Update(&md5_struct, &buffer, bytes_read) == 0 )
			return (0);
	}
	
	if ( MD5_Final(result, &md5_struct) == 0 )
		return (0);
	
	/*  Format the digest */
	for ( i=0; i<MD5_DIGEST_LENGTH; ++i ) {
		sprintf(tmp_hex, "%02x", result[i]);
		strcat((char *)digest, tmp_hex);
	}
	
	close(file_d);
	
	return (1); /* Success */
	
}
main.c
Code:
#include <stdio.h>
#include "md5file.h"

int main (int argc, const char * argv[]) {
	
	char md5_digest[33];
	
	md5_file(argv[1], md5_digest);
	
	fprintf(stdout, "%s\n", md5_digest);
	
    return 0;
}