Re: reading from a string

Ettore Virzi (ettore@inorg195.csmtbo.mi.cnr.it)
Fri, 21 Feb 1997 14:52:54 +0100 (GMT+0100)

To subscribers of the xforms list from Ettore Virzi <ettore@inorg195.csmtbo.mi.cnr.it> :

>
> I am trying to get the input back from a field in a normal type input
> field. The problem is that i dont quite understand the documentation about
> the
>
> [const] char *fl_get_input(FL_OBJECT *obj)
>
> I presume this returns a pointer to the first element in the string.
> Therefore successive incrementation should produce the next in the string.
> But I get the value of the next letter in the alphabet. I have tried
> several different ways but all failed.
> I would be very grateful of any helpful suggestions about this.
>
> Code fragment below - in callback file.
> -------------------
> char *plain;
> char store[100];
> int x=0;
>
> void plaintext_cb(FL_OBJECT *ob, long data)
> {
> *plain = *fl_get_input(ob);
> for(x=0;x<=4;x++)
> {
> store[x]=*plain;
> plain++; // I am sure I have to reference the address here.
> printf(">%c\n",store[x]);
> }
> }
>
Your problem is surely enough in the deferentiation of the return value of
fl_get_input. After:
*plain = *fl_get_input(ob);
plain isn't really pointing to anything!!
The code should be:

plain = fl_get_input(ob);
strcpy(store, plain);

and now you are able to do anything you want wiht your string.
Have Fun!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ettore Virzi
ettore@inorg195.csmtbo.mi.cnr.it
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_________________________________________________
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/xforms-archive/