Re: simple integer addition



On Mon, 2001-09-03 at 20:02, manchalapraveenk reddy wrote:
hi all,
can u plz let me know how the diff data types a are
handled i would like to know how is this handles as
suppose we have three text entries the contents of the
first two should sum up and must give it in the third
entry after a button click event .What r the diff.
availabel dataypes in GTK+ for some calculus
programming.

Well, the different data-types you can have in an entry are:

        1. const char*

If you need a datatype not in the list above, you need to extract it
from one of the available somehow. Let's say you want to do integer
addition. Then you want to extract an int from each of the two input
entries, i.e. you want to translate to strings (in form of char*) into
integers. This can can achive using for example atoi. Then you want to
translate the sum back into a string. For this you can use e.g.
snprintf.

I've attached a small program that adds the contents of two entries and
put the result in a third. That should show you the idea.

        /mailund

-- 
87 % of all statistics are just made up

Attachment: main6.c
Description: Text Data

Attachment: pgpxZcSCT8mCL.pgp
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]