Question

Ok I am planning on making a file for storing data that I will be importing into a program. This program is to be compiled for Linux, Windows, and potentially Mac.

Now what I really want to know is would I need these data files to be slightly different due to the newline character in these files or would stdin not be picky about what system I am on?

Will it be a problem or not? If so what is the proper way to overcome these problems? Also are there any other problems I may be over looking?

No correct solution

OTHER TIPS

If the program is not intended to be read by the user, just make sure that you output it in the same form that it will be input. In this case, it may be easier to use a binary format.

Regardless, make sure you set your stream to be binary, otherwise Windows may expand \n into \r\n for text streams.

Alternately, one of the simplest ways to overcome this problem in a platform-agnostic way for text files that are intended to be user-read is to greedily consume all adjacent \r and \n characters as a single line ending, and you won't have to worry about how you output it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top