Jump to content
  • Advertisement
Sign in to follow this  
pascalosti

how 2 show date in console c++

This topic is 4343 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
You can use the asctime() and localtime() functions in the ctime header, or if you're feeling adventurous, you can try using the time_put locale facet.

Share this post


Link to post
Share on other sites
so something like this?

#include <iostream>

#include "ctime"
using namespace std;

int main(){
cout <<asctime()<<endl;

cout << localtime() << endl;

return 1;
}

Share this post


Link to post
Share on other sites
You put the ctime in brackets, like this <ctime>. Just like <iostream>.

EDIT: Actually, that code does work, but it is considered bad style.

Share this post


Link to post
Share on other sites
this is the error i get? im using visual studio 2005

Error 1 error C2661: 'localtime' : no overloaded function takes 0
Error 2 error C2661: 'asctime' : no overloaded function takes 0

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!