Well, I almost went nuts on this one. Along with my trusty cohort Rob Noah, we were making a program that wrote out gif files. It worked fine on Unix. When I ported to Windows, we made sure the "int's" were 4 bytes but it still didn't work. After close analysis we discovered that for every "10" or "OA" we wanted to write to the file, Windows was actually writing "13 10" or "OD OA".
You might THINK that this would be easy to detect, but when I read in this file (on Windows) every "13 10" pair was read in as just "10". By moving the files to UNIX and looking at them there, and by checking out the file size on Windows I was able to figure it out.
So what is the solution? It is to use "fopen" properly. If you are a UNIX programmer, you probably never think about it because if you are a UNIX programmer you are lucky enough to work on an OS that doesn't second guess the programmer. If you are on Windows ...
fopen("filename","wb") ;Instead of just fopen("filename","w") like you always do on UNIX. If you don't always do this on UNIX, then you probably aren't reading this page.
Return to Gene's Home Page
Return to Gene's Random Unix Crap