Re: writing text files withe OPENW and PRINTF [message #48397] |
Wed, 19 April 2006 19:23 |
valar.mu
Messages: 1 Registered: April 2006
|
Junior Member |
|
|
Hi,
I was trying to write the parameter file for the HEG tool with C++. I
had similar problems with the carriage return and new line character.
Then, I tried writing the output file (parameter file) in binary mode
and used only '\n' wherever a new line is needed. It works now.
Hopefully, this solves your problem!
Valar
|
|
|
Re: writing text files withe OPENW and PRINTF [message #48402 is a reply to message #48397] |
Wed, 19 April 2006 13:51  |
Michael Galloy
Messages: 1114 Registered: April 2006
|
Senior Member |
|
|
Michael Wallace wrote:
> No one has responded yet, so I guess I might as well say something. It
> sounds like the age old linefeed/carriage return issue.
I thought this too, but I'm not sure why this would happen in his case.
Also, the two files seem to be identical (the same exact 885 bytes). I'm
wondering if my newsreader is doing the conversion for me.
Mike
--
www.michaelgalloy.com
|
|
|
Re: writing text files withe OPENW and PRINTF [message #48404 is a reply to message #48402] |
Wed, 19 April 2006 12:09  |
Michael Wallace
Messages: 409 Registered: December 2003
|
Senior Member |
|
|
No one has responded yet, so I guess I might as well say something. It
sounds like the age old linefeed/carriage return issue. I'd understand
the problem if you were taking data from a *nix system to a Windows
system or vice versa. However, it doesn't appear that you're doing this.
Anyway, the end of line on a Windows system is denoted by the carriage
return and linefeed characters. However on Unix based systems, only
linefeed is used to note the end of line. Therefore a Windows file
viewed on Linux will appear to have extra characters. And a Unix file
viewed on Windows will have missing characters. Many programs on Unix
and Windows are now built to check for files in the other format and
open them accordingly. However, Windows Notepad is not one of those
programs. Because there are no carriage return characters, it appears
that all the text of the file is on a single line.
There are a couple programs, unix2dos and dos2unix that will convert
files back and forth between the formats. Those were originally written
for Unix systems, but I believe there are Windows ports these days.
Anyway, I realize that none of this really explains your particular
error, but maybe it's something you can look into.
-Mike
daevu wrote:
> Folks...
>
> Writing an input parameter file under windows for an external tool
> became my main easter occupation: Attached two parameter files:
> works.prm and dontwork.prm, both have the exact same content, but opened
> in notepad.exe the works.prm is all on one line, but it contains a
> carriage return informations can be seen if opened eg. in MSWord.
> I tried to create a file with the same information using the code below,
> and end up with the file dontwork.prm: it looks exactly like the
> works.prm but will not be read by the external program (its the HEG tool
> to convert MODIS data actually)
>
>
> - which format does the dontwork.prm have? obviously not standard MS-DOS
> - are there ways to write in IDL under windows non MS-DOS formatted
> text files?
>
|
|
|