Member Avatar for ee_girl

Hi!, I'm a first-year student at the university. When i am using Tubo C++ , i encountered a problem with inputting Date to graphics window. The code below here is the way to input date in text window, but i dont know how to input this into the gaphics window, because we have to use "outtextxy" in th graphics window not "gotoxy".

#include<graphics.h>

struct date d;
getdate(&d);
        gotoxy(65,1);
        cprintf("%d/", d.da_day);

Thanks in advance!!

Use sprintf() or a std::ostringstream to convert the date to a string, then use outtextxy() to print the string.

char buf[ 20 ];
sprintf( buf, "%d/", d.da_day );
outtextxy( 200, 100, buf );
// I'm pretty sure that Turbo C++ uses a different header name
// for the stringstream... it might be <stringstream>
#include <sstream>
...

ostringstream ss;
ss << d.da_day << "/";
outtextxy( 200, 100, ss.str().c_str() );

Hope this helps.

> I'm a first-year student at the university. When i am using Tubo C++
What are you studying? Archaeology or history?

It's probably so old it doesn't understand the namespaces which Duoas posted.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.