Tech Support Guy banner
Status
Not open for further replies.

c++: Getting current time

2K views 1 reply 2 participants last post by  Shadow2531 
#1 ·
I was wondering if anyone could give me an example of some source code that could give the time in the form of HH.MM

i know it can be done as follows but i need it in the above format so i can search an array for that time.

Code:
#include <iostream>
#include <time.h>
#include <string.h>

main()
{
  char currenttime[26];
  time_t t;
  time(&t);
  strcpy(currenttime, ctime(&t));
}
the problem with this is that it out puts the time in the format

www MMM dd hh:mm:ss yyyy

where w is the weekday
M is the month in letters
d is the date in the month
h is the hour
m is the minute
s is the second
y is the year

could i make a string by taking the hour.minute and comparing them against the times (the times in the array ar in teh format 7.56, 17.38 etc)

thanks,
nnp
 
See less See more
Status
Not open for further replies.
You have insufficient privileges to reply here.
Top