This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
>To: address@hidden >From: Igor Pesenson <address@hidden> >Subject: Re: 20030203: subject >Organization: Lawrence Berkeley National Laboratory >Keywords: 200302031956.h13Ju0623075 Igor, > Thank you Russ, someday I'll get the array/pointer deall all correct. My date > string is declared > as: > > char base_time_str[25]; > > And initialized as: > > strftime(base_time_str,25,"%d-%b-%Y,%H:%M:%S GMT", ×truct); > > Where timestruct is of type (struct tm). Anyhow, base_time_str ends up a very > nicely formed > string. > Then my code says: > > nc_status=nc_def_var(ncid,"base_time",NC_INT,0,&idimid,&ivarid[1]); > nc_status=nc_put_att_text(ncid,ivarid[1],"string",25,base_time_str); > > However, the output looks as: > > int base_time ; > base_time:string = "" ; > > What am I missing? I'm sorry to be pounding this to death, but I haven't been > able to get very > far with all this in the last few days. Thank you, > Igor. > PS Playing with your solution to my other issue of the 15-long binary flags > was very intersting > is worked great. Thanks! It doesn't look like there is anything wrong with your nc_put_att_text call, so I suspect by the time it is called, base_time_str doesn't contain what you think it should have in it. Could I get you to print the value of base_time_str just before the call by inserting a printf() call: nc_status=nc_def_var(ncid,"base_time",NC_INT,0,&idimid,&ivarid[1]); printf("base_time_str is '%s'", base_time_str); nc_status=nc_put_att_text(ncid,ivarid[1],"string",25,base_time_str); It might also be a good idea to check the status returned by these calls, since that's the only way run-time errors can be detected. --Russ _____________________________________________________________________ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu