Re: XForms: problems with fl_get_choice_text

Joel Weiner (weiner@mcci-arl-va.com)
Thu, 6 Nov 1997 10:08:09 -0500

To subscribers of the xforms list from weiner@mcci-arl-va.com (Joel Weiner) :

>> sscanf((char *)datum(),"%*s %s %d %s %d",monat,&tag,time_string,&jahr);
>>
>> int tag;
>> char monat[6];
>> int jahr;
>> char *time_string;
>>
>> /* (tag=day, monat=month, jahr=year)
>>
>> datum() returns something like "Thu Nov 6 11:12:34 1997"
>>
>> and the sscanf should get the things into the different variables
>>
>> %*s omits the first (Thu)
>> %s writes "Nov" into monat (=char monat[6])
>> %d writes 6 into tag
>> %s writes "11:12:34" into time_string
>> %d writes 1997 into jahr
>>
>>
>> time_string is a pointer, is it set to point to allocated storage?
>> or should it be char time_string[6] ??

I believe that sscanf requires time_string to point to allocated memory.

The manpage for sscanf says:
s A character string is expected; the corresponding
argument should be a character pointer pointing to
an array of characters large enough to accept the
string and a terminating \0, which will be added
automatically. The input field is terminated by a
white space character.

jhw
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
Xforms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/