i am writing a program that i need to check the date, and return it as a value. does anyone know what i should do to make it read the date? i dont know where i would tell it to look. thanks.
i am writing a program that i need to check the date, and return it as a value. does anyone know what i should do to make it read the date? i dont know where i would tell it to look. thanks.
Look up some of the functions in time.h
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.
You may think that the answer to this should be REALLY easy, and I suppose I could make a very easy answer - but I prefer to give you GOOD help rather than EASY FOR ME help.
Besides getting the current date/time, what do you want to do with it? Just print it, or do some calculations or some such?
--
Mats
i want to write a program to tell me the date every time i start the comp. i can make it autorun, but i just need to figure out how to make it tell me the date. and ty, i will look up time.h. any more help is appreciated
What's wrong with this batch file?
--Code:// file: timedate.bat date < NUL: >> mytimestamp.txt time < NUL: >> mytimestamp.txt
Mats
I'm not sure what the purpose of the < NUL: is, but a better version (without the Enter new Date prompts) is:
You can also check the System Event Log to see when the system starts & stops (i.e. check when the Event Log service starts & stops).Code:@ECHO OFF DATE /T >> C:\SystemStart.txt TIME /T >> C:\SystemStart.txt
The < NUL: is there to avoid the "enter new date" prompt - I didn't know that recent versions of Windows support an option to avoid that...
NUL: is the same as /dev/null in Unix/Linux, that is, a device that just returns end of file when read and "eats" anything written to it without any further processing. So a good place to input nothingness and a good place to get rid of unwanted output.
--
Mats
how can I check the username of the windows account that logged in?
So I can make a app of the time/date/username who logged into windows..
http://msdn2.microsoft.com/en-us/library/ms724432.aspx
As per MSDN instructions, include Windows.h, and link with Advapi32.lib.
Call it with something like this:
Code:#include <Windows.h> ... char szUsername[256]; ... GetUserName(szUsername, sizeof(szUsername)); /* szUsername now contains the current Windows username */