C++ School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a C++ Expert!

Join 300,431 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,503 people online right now. Registration is fast and FREE... Join Now!




Appending a number to the end of a string to display in GLUI_ EDITTEXT

 

Appending a number to the end of a string to display in GLUI_ EDITTEXT

bushimports

26 May, 2009 - 01:15 PM
Post #1

New D.I.C Head
*

Joined: 21 Aug, 2008
Posts: 13

What I am trying to do is when I click a button it draws a cube or whatever and displays the name of the object in a
GLUI_EDITTEXT_TEXT box.I also want to append a number to the end of the object name and increment the number each time a new object is drawn. I have everything working ok except the name and number will only display one character at a time in the textbox and increments the position each time the draw button is pushed. Much Thanks to anyone who will/can help with this. Jody Bush
Below is part of the code I have for this thing.
CODE
//My variables
int Cnum = 1;
int Pnum = 1;
char Cube[sizeof(GLUI_String)] ={" "};
char Plane[sizeof(GLUI_String)] ={" "};
char Name;

//my glui edittext
Name1 = subwin->add_edittext( "Name", GLUI_EDITTEXT_TEXT,&Name);

//my callback functions
if(control == DRAWPLANE_ID){
      drawplane = true;
       sizex = 1.0;
       sizey = 1.0;
       sizez = 0.0;
       itoa(Pnum, Plane, 10);
      sprintf(Plane,"Plane %d",Cnum);
      Name = Plane[Pnum];
      Name1->get_text();
      Pnum++;
}

if(control == DRAWCUBE_ID){
      drawcube = true;
      sizex = 1.0;
      sizey = 1.0;
      sizez = 1.0;
       itoa(Cnum, Cube, 10);
      sprintf(Cube,"Cube %d",Cnum);
      Name = Cube[Cnum];
      Name1->get_text();    
      Cnum++;
}


This post has been edited by bushimports: 26 May, 2009 - 01:20 PM

User is offlineProfile CardPM
+Quote Post


janotte

RE: Appending A Number To The End Of A String To Display In GLUI_ EDITTEXT

27 May, 2009 - 03:40 AM
Post #2

code > sword
Group Icon

Joined: 28 Sep, 2006
Posts: 2,157



Thanked: 152 times
Expert In: C/C++

My Contributions

Mods

This looks like it belongs in C/C++.


User is offlineProfile CardPM
+Quote Post

NickDMax

RE: Appending A Number To The End Of A String To Display In GLUI_ EDITTEXT

27 May, 2009 - 08:14 PM
Post #3

Can grep dead trees!
Group Icon

Joined: 18 Feb, 2007
Posts: 5,216



Thanked: 285 times
Dream Kudos: 1175
Expert In: Java/C++

My Contributions
Moving to C++
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic

Time is now: 11/8/09 12:43AM

Live C++ Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month