Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in C only
Search
Advanced Search
Forums
BYTES
Product Launch
Updates
Developer Toolkit
Today's Posts
Member List
Calendar
Home
Forum
Topic
C
C++ program on dates
Collapse
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
novicedelight
New Member
Join Date:
Jul 2007
Posts:
2
#1
C++ program on dates
Jul 4 '07, 12:47 AM
hela'zZz;
kindly tell me what to do in making c++ program on dates please...... kinda novice programmer in here.....
archonmagnus
New Member
Join Date:
Jun 2007
Posts:
113
#2
Jul 4 '07, 03:50 AM
What exactly are you wanting to do concerning the usage of the date? If you just want to output the date, you can use the "time" and "ctime" functions (oddly enough from the "ctime" library file) as evidenced in the following code:
[code=cpp]
#include <iostream>
#include <string>
#include <ctime>
using namespace std;
int main (int argc, char *argv[])
{
string time_string;
time_t timeInfo;
timeInfo = time(NULL);
time_string = ctime(&timeInfo );
cout<<"The current time is: "<<time_string< <endl;
return 0;
}
[/code]
Note that the value returned from "ctime" contains a newline character and is null terminated.
Comment
Post
Cancel
Previous
template
Next
Working...
Yes
No
OK
OK
Cancel
👍
👎
☕
Comment