Okay i am trying to get this file reading thing to work, and so far i am failing misserably. i am getting the "segmentation fault" error, which has to do with my char array i figure, but i have played with it in every way that i know how and i can't get it to work correctly. can anyone give me any advice here to point me in the right dirrection or tell me what i am missing?
thanks a lot for your time and help!!!
#include <stdio.h>
int main()
{
int inFile, outFile;
FILE *stream;
FILE *ostream;
int numread, numwritten;
char *s;
s=(char*) malloc(10000); memset(s,0,10000);
char outFileName[]="out_test";
char InFileName[]="in_test";
/*writeable file*/
ostream = fopen(outFileName, "w");
stream=fopen(InFileName, "r");
/*read from a file,copysize to numread*/
numread=fread(s,1,9999,stream);
/*write to file*/
fwrite(s,1,numread,ostream);
/*close files*/
int fclose(FILE *stream);
int fclose(FILE *ostream);
}
thanks a lot for your time and help!!!
#include <stdio.h>
int main()
{
int inFile, outFile;
FILE *stream;
FILE *ostream;
int numread, numwritten;
char *s;
s=(char*) malloc(10000); memset(s,0,10000);
char outFileName[]="out_test";
char InFileName[]="in_test";
/*writeable file*/
ostream = fopen(outFileName, "w");
stream=fopen(InFileName, "r");
/*read from a file,copysize to numread*/
numread=fread(s,1,9999,stream);
/*write to file*/
fwrite(s,1,numread,ostream);
/*close files*/
int fclose(FILE *stream);
int fclose(FILE *ostream);
}