Unidata - To provide the data services, tools, and cyberinfrastructure leadership that advance Earth system science, enhance educational opportunities, and broaden participation. Unidata
         
  advanced  
 

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
 |||| | | | |  |  |  |   |   |    |    |    |   |   |  |  |  |  | | | | | ||||

 
 
  Contact Us     Site Map     Search     Terms and Conditions     Privacy Policy     Participation Policy
 
National Science Foundation (NSF) UCAR Community Programs   Unidata is a member of the UCAR Community Programs, is managed by the University Corporation for Atmospheric Research, and is sponsored by the National Science Foundation.
P.O. Box 3000     Boulder, CO 80307-3000 USA     Tel: 303-497-8643     Fax: 303-497-8690