0

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!!

3
Contributors
2
Replies
4
Views
9 Years
Discussion Span
Last Post by Salem
0

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.

0

> 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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.