NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

Re: Problems with Strings

> long start[MAX_DIMS] = {0, 0};
> long count[MAX_DIMS] = {2, 30};
> ncvarget(cdfid, start, count, &value);
>
> After this operation value contains the data in this way:
> <string1><string2>, e.g. JohnPaul
>
> So, how can I know which part is the first string and which is the second.
> There is no delimiter set, and I only know that the max. string length is 30.

In the C language, strings are terminated with ASCII NUL (ASCII value 0).
NULs are invisible, so it's possible that the contents of value could be

        John\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0Paul\0\0\0...
        
If this guess is correct, then e.g. strcpy(value[0],string1) 
and strcpy(value[1],string2) should copy John and Paul separately.


Bill


   William Weibel                           weibel@xxxxxxxxxxxxxx
   UCLA Department of Atmospheric Sciences  Tel. (310)206-4441       \\\\/
   Los Angeles, CA  90095-1565              Fax  (310)206-5219        O-O
   U.S.A.                                                              |
                                                                       -
   'Why,' said the Dodo, 'the best way to explain it is to do it.'
                                Alice's Adventures in Wonderland
 |||| | | | |  |  |  |   |   |    |    |    |   |   |  |  |  |  | | | | | ||||

  • 1996 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: