I've watched this thread for 5 days now. Ami123 is correct when he refers to the inefficiency of character by character file IO. In general you don't want to do that.<br><br>What you want to do is block IO operations. So you read in a block at a time into a memory buffer. Process the buffer then write the memory buffer into the target file. So, if I understand the original problem correctly to produce a copy of the original file where all semicolons have be replaced with commas it would look like this:<br><br>const int BUFSIZE = 1024;<br>char buf[BUFSIZE];<br>char* psemi;<br>size_t nBytesRead;<br>FILE *inf, *outf;<br>inf = fopen("data.dat", "r"

;<br>outf = fopen("fdata.dat", "w"

;<br>memset( buf, 0, BUFSIZE);<br><br>while ( 0 < (nBytesRead = fread((void*)buf, 1, BUFSIZE -1, inf)) ){<br> buf[nBytesRead] = '\0';<br> while ( 0 != (psemi = strchr(buf, ';')))<br> *psemi = ',';<br><br> fwrite( buf, 1, strlen(buf), outf);<br>}<br><br>fclose(inf);<br>fclose(outf);<br><br>If you time the file IO operation and adjust the buffer size you will find the optimal buffer size for a give machine OS combination. 1k, 2k, 4k, 8k, 16k... etc.<br><br>Now all you have to do is supply the file names in place of the hard coded values and add error checking etc.<br><br>Good luck<br>-pete<br>