>>2 can you do this without reading the whole string into memory?
Yes. Did you copy this from some old reddit discussion?
Name:
Anonymous2007-08-24 4:55 ID:cXjzk3hW
Yeah, load the first and last 32KB into memory. Reverse that string. Write them back. The repeat with the the next 32KB chunks towards the centre until done.
maybe something like this? fseek(input_stream,0,SEEK_END);
for(int i=ftell(input_stream);i+1;fseek(input_stream,--i,SEEK_SET))
fputc(fgetc(input_stream),output_stream);
Name:
Anonymous2007-08-24 10:45 ID:g5GfqWql
If you're on some primitive machine with only 64kb of RAM, I think most of the trickiness (in terms of speed, and also in terms of getting things to work if you truly only had 64k and were talking directly to the disk) would revolve around the string not being an even multiple of your disk's sector size.