Hammer, thanks for the guidance. For some reason I just did not think the copy would work like that.
Anyway, I am almost there. I am getting my file to be read, and the data is being writen to the new file with a new line for each bit of space, But when I open the new file that the data was writen to, I am seeing some character and not the actual data that was in the read file. I am guessing I have something wrong with my fputc command in my code or maybe my fgetc. Anyone have any ideas? here is my current code.
Code:
#define W_S (sp == ' ' || sp == '\n' || sp == '\t')
void fileIO (void)
{
int c;
int sp;
int Status;
FILE *fp1;
FILE *fp2;
if (!(fp1 = fopen("file1.dat", "r")))
{
printf("Error opening file for reading\a\n");
return;
}
if (!(fp2 = fopen("file2.dat", "w")))
{
printf("Error opening file for writing\a\n");
return;
}
while ((sp = fgetc(fp1)) !=EOF)
{
if (W_S)
{
fputc('\n', fp2);
}
else
fputc(c, fp2);
}
fclose(fp1);
Status = fclose (fp2);
if (Status == EOF)
{
printf("Error closing write.dat file\a\n");
return;
}
return;
}
instead of isspace() I just defined whitespace (only because I am unfamiliar with isspace. I will be looking that one up, sounds like it would do the job much nicer for me. But basically there it is. Any ideas as to what I did that is causing my data to be turned into a strange character (looks like: Ì) instead of the actual data?
Thanks for taking the time.
DD