NULL Termination

Freddie Akeroyd faa at isise.rl.ac.uk
Fri Sep 17 12:00:33 BST 1999


I'm not convinced strings written by C always have a '\0' on them! As HDF
stores (data, type, length), it doesn't need to and the only way it will
be there is if you specify "strlen(string)+1", which isn't the natural
thing to do. The NeXus API currently adds a '\0' onto the returned data
for you when you read a string attribute, but FORTRAN doesn't need this
(and it will probably show up as an unprintable character). The only
situation not covered at the moment is "getdata" for "string arrays" ...
maybe this is where we should explicitly write a '\0' into the file?

Freddie  

On Fri, 17 Sep 1999, Mark Koennecke wrote:

> 
> It ocurred to me that we must make sure that any character data written from F77
> has a 0 at the end of
> the string otherwise we get in deep trouble when reading that from a C program.
> Again,  I think this should be handled automatically by the API.
> 
> 
> Mark
> 

-- 
Freddie Akeroyd                        Email:  Freddie.Akeroyd at rl.ac.uk
ISIS Facility                          Tel:    +44 1235 445457
Rutherford Appleton Laboratory         Fax:    +44 1235 445720
Chilton, DIDCOT, OX11 OQX, GB          WWW:    http://www.isis.rl.ac.uk/




More information about the NeXus-developers mailing list