How to make a programm to display the current time on the command prompt
how to read the time from the system clock
i know i have to include time.h but i don't know the function's to do it
How to make a programm to display the current time on the command prompt
how to read the time from the system clock
i know i have to include time.h but i don't know the function's to do it
There's what - a dozen functions in time.h tops?
Maybe read the manual page for each one and then think about which can be used to solve the problem.
Several can be used in several ways, but that's beside the point.
You need to do some research of your own and come up with an attempt.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
i read this on my tutorial but there isn't any tutorial to teach me how to use this function to display the time on the screenGet the current time from the system clock. Stores that value in timer. If timer is null, the value is not stored, but it is still returned by the functionCode:time_t time(time_t* timer)
Last edited by Dave_Sinkula; 04-14-2007 at 02:24 PM. Reason: Code tags are spelled [code][/code] -- not [tag][/tag].
if Windows;
Code:#include <windows.h> #include <iostream> int main() { SYSTEMTIME date, time; GetLocalTime(&date); GetLocalTime(&time); int a=time.wSecond; int b=time.wMinute; int c=time.wHour; int x=date.wMonth; int y=date.wDay; int z=date.wYear; std::cout<<x<<"-"<<y<<"-"<<z<<" is the date"<<std::endl; std::cout<<a<<":"<<b<<":"<<c<<" is the time"<<std::endl; std::cin.get(); }
Well look at other functions which take either a time_t or a time_t* parameter and see if they get you closer to your goal.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
strftime(buf, sizeof(buf), "%a %Y-%m-%d %H:%M:%S %Z", &ts);
i have this part of code where buf is char of 50 characters and ts is tm structure i dont know how strftime place the current time in buf
So go research strftime().
You'd think the forums are an interactive dictionary. We're not all librarians, paid to do your research for you.
http://www.google.com/search?hl=en&q...=Google+Search
Oh, look. The second entry on google deals with C/C++.
http://opengroup.org/onlinepubs/0079.../strftime.html