I have ben scratching my head at this code for the last 2 days now and cant figure out what i have done wrong! i am trying to get the code to read from the txt file one bite at a time and then write this bite into the binary file but i cant seem to get it working. Please help me!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
FILE *fpcust, *fpcustbin; //<<<<<-----point to both sales and customers text files, and the new .bin files for both
char buffer;
int ch;
int ch1;
fpcust = fopen("c:\\customers.txt", "r"); //<<<<-----pointing to the file
fpcustbin = fopen("c:\\customers.bin", "wb"); //<<<<<-----pointing to the new binary file, opening in writing binary
while ( ( ch = fgetc ( fpcust ) ) != EOF )
{
fread(buffer, 1, 1, fpcust); //<<<----these two lines are copying the text in the first file and pasting in binary into the new binary file while not = EOF
fwrite(buffer, 1, 1, fpcustbin);
}
fclose(fpcust); //<<<<-----closing the text file....may have to change to file pointer
fclose(fpcustbin); //<<<<------closing the binary file ....may have to change to file pointer