954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Problem with insert Date and Time in graphics

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

ee_girl
Newbie Poster
1 post since Aug 2008
Reputation Points: 10
Solved Threads: 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.

Duoas
Postaholic
2,043 posts since Oct 2007
Reputation Points: 1,140
Solved Threads: 229
 

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

Salem
Posting Sage
Team Colleague
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You