Quote:
Originally Posted by DaWei
Yeah, a hex editor showed me the unicode. You may have a number of other issues. The length given to fgets does not specify how much you read, but a maximum to read if a newline is not found. You may be aware of this, but your code doesn't indicate so. I would still be leery of trying to read the super long strings with fgets, unless you find it works on YOUR system, and you have absolutely no qualms about non-portability. Personally, I'd use fread for copius amounts of material. I don't know what compiler you're using, but the definition of main, "int main (int argc, char *argv[0]){...}" won't work with a compliant compiler, as one can't declare an array (argv) of 0 bytes. Also, if opening file 1 succeeds, but opening file 2 fails, you don't close file 1 before exiting. The system will take care of this for you, generally, but you may lose file handles, of which there are a limited number. It's a bad habit to get into.
Thanks for the additional commentry. I will tidy up the closing of f1 if fail to open f2 but since I'm trying to engineer a cheap & cheerful solution for a current project & am not worried about portability I'll forge ahead on the fgets (I know the length of the largest string I'll encounter < 24K chars). All the best, Terry