dissathep
asked on
Null pointer assignment
/***** Program Merge many files to one file *****/
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<io.h>
#include<dos.h>
#include<string.h>
#include <fcntl.h>
#include <sys\stat.h>
#define BUFSIZE 54
int main(int argc,char *argv[])
{
extern int errno;
void *point;
FILE *fpw,*fpr;
int count;
int handle;
int errchk;
long filesize;
for(count=1;count<argc-1;+
{
free(point);
handle = open(argv[count],O_RDONLY|
filesize = filelength(handle)-3;
printf("\n%d----%d\n",hand
if((point = malloc(filelength(handle))
{
printf("Not enough memory to allocate buffer\n");
exit(1); /* terminate program if out of memory */
}
/****** READ FROM SOURCE FILE ******/
if((errchk = read(handle,point,fileleng
{
printf("Read Failed.\n ----%d",errno);
exit(1);
}
else
{
close(handle);
}
/****** WRITE TO TARGET FILE ******/
if((fpw = fopen(argv[argc-1],"a+t"))
{
fprintf(stderr, "Cannot open input file.\n");
return(1);
}
else
{
fwrite(point,filesize,1,fp
fclose(fpw);
free(point);
}
}
return(0);
}
Above is my merging program source code for merge detail in many files to one file.It work completely but after close target file appear message "Null pointer assignment" on screen.Can you correct this error message or any error may have on source code ?.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.