![]() |
|
#1
|
|||
|
|||
How to create integer variablesHello,
I have recently created a basic game of battleships using C++ and am looking to adapt it to work in a FLTK GUI. However I'm far from an expert and need a little help. To start with I am trying to create a simple FLTK piece of code that allows a user to enter two seperate integers into two seperate text boxes. On the click of a button I then want to store these integers as standard integer variables so I can perform some basic arithmatic operators on them. At present I can only figure out how to store them as strings. If anyone has any ideas or if they can provide the code, as I have a feeling it may not be all that complicated. Please help me out. Many thanks Oli |
|
#2
|
|||
|
|||
|
Quote:
Hi, You dont say which FLTK version you are using, but here is code for 1.x: CPP / C++ / C Code:
For FLTK2 code is same, but replace "Fl_" with "fltk::" Hope this helps. |
|
#3
|
|||
|
|||
Further QueryFirstly thanks for the previous help, it help solved part of the problem and is greatly appreciated.
However I still have one small problem, I am now looking to output integer variables into a textbox. So far the code I have is: CPP / C++ / C Code:
The template of this program is something that came with my fltk install, however I am using it as a practise tool. Within the callback function I want to place the contents of the 'val2' variable within the 'outBox' textbox. If I were dealing with a string I understand I would use 'outBox->value(val2.c_str());'. However this does not work for an integer so I am basically looking for the integer equivalent. Any help anyone can provide would be greatly appreciated. Many Thanks Ollie P.S: I am using the 1.10 version of fltk |
|
#4
|
|||
|
|||
|
First of all, I suggest you to update FLTK version to atleast 1.1.6
Anyway, here's code: CPP / C++ / C Code:
Hope this helped. BR, Mikko |
|
#5
|
|||
|
|||
ThanksAbsolute legend. Worked perfectly.
Thanks Oli |
Recent GIDBlog
Writing a book by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| passing variables out of an iframe by url | JUNK KED | MySQL / PHP Forum | 5 | 31-Jul-2007 10:33 |
| Function and Array (w/ reference variables) question | brookeville | C++ Forum | 15 | 07-Dec-2004 02:11 |
| Help! Some basal questions about MFC | xutingnjupt | MS Visual C++ / MFC Forum | 1 | 05-Dec-2004 04:38 |
| Can't seem to create db | Tigress7 | MySQL / PHP Forum | 3 | 19-Aug-2003 10:19 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The