Mail Archives: cygwin/1997/06/03/09:49:50
Bala Amavasai[SMTP:B DOT Amavasai AT sheffield DOT ac DOT uk] wrote:
>Hi! I wonder if anyone can help. I've written a short program to remove a
>fix sized header (of 512 bytes) from a raw image file. However when I
>compile it and run under gcc b18, I do not get the output I expect. That
>is the output file size is always 30 bytes. The same code compiles and
>works perfectly in Solaris 2.4 and Linux 2.0.27. The truncated version of
>the code is fowarded below.
See below, it's a binary vs. text problem.
>Another problem which I'm facing is that when I allocate a large array,
>say 1000x1000 and when I read and write data to/off it, I get junk towards
>1/4 way into the array. Once again the same code works very well in the
>platforms above. Is there a problem with memory allocation? I'll send a
>truncated piece of code later, unless the problem has been previously
>logged.
I've never heard of this and would be interested to know the specifics.
> /* image file */
> if ((infile=fopen(argv[1],"r"))==NULL)
Change to fopen(argv[1],"rb"). Files are opened by default in text mode, which is, unfortunately, not the same as binary on win32 machines (and yes there has been a lot of arguing back and forth about what GNU-Win32 should do about it). If you open your files in binary mode then it should work on both UNIX and Win32.
> /* create temp file */
> if ((outfile=fopen("outfile","w"))==NULL)
Change to fopen("outfile","wb") as above.
-- Colin Peters - colin AT bird DOT fu DOT is DOT saga-u DOT ac DOT jp
-- Saga University Dept. of Information Science
-- http://www.fu.is.saga-u.ac.jp/~colin/index.html
-- http://www.geocities.com/Tokyo/Towers/6162/
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".
- Raw text -