How to convert a struct * to a type variable const * char?

0

I'm using a third-party library called "graphics" with which I'm trying to show a binary tree type data structure graphically, my problem is that there is a function called:

outtextxy(posicionX,posicionY,const *char)

and I have a struct done like this:

struct ABB {
   int dato;
   ABB *der;
   ABB *izq;
   ABB *padre;
}*arbol;

The data is normally entered in the struct but I can not show it in the function because it is not of type const * char ... What I want to do is convert that data into the struct in a const * char variable so that it allows me to enter them in the outtextxy function but I can not find a way to do it! I hope you can help me with this !!!

Here I show the code of the function outtextxy

void outtextxy(int x, int y, char *textstring){
 HDC hDC = BGI__GetWinbgiDC( );
WindowData* pWndData = BGI__GetWindowDataPtr( );

// check alignment
if (pWndData->alignment != TA_NOUPDATECP)
{
pWndData->alignment = TA_NOUPDATECP;
set_align(pWndData);
}

TextOut(hDC, x, y, (LPCTSTR)textstring, strlen(textstring));
BGI__ReleaseWinbgiDC( );

RefreshWindow( NULL );
// Todo: Change to refresh only the needed part.}
    
asked by user73355 15.05.2018 в 00:25
source

1 answer

0

What the outtextxy function receives is a text string. To show the values of your struct you should first generate a text string with what you want to show. You can do something like this:     struct ABB * node; // the pointer to the node that you want to show     int x, y; // the position where you want to write     char buffer [1024]="";     sprintf (buffer, "data:% d", node-> data);     outtextxy (x, y, buffer);

sprintf is like printf , but writes in char * . Check the documentation of sprintf or prinft to see the options you have to format the description of your node.

    
answered by 28.05.2018 в 21:55