Date Recongnition
I am currently trying to create a program that can identify the day as a number (todays current date is June 17, 2010).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
#include <cstdlib>
#include <iostream>
#include <stdio.h>
#include <time.h>
using namespace std;
int main(int argc, char *argv[])
{
{
int date;
time_t rawtime;
struct tm * timeinfo;
char buffer [80];
time ( &rawtime );
timeinfo = localtime ( &rawtime );
date = (strftime (buffer,4,"%d.",timeinfo));
if (date == 17)
cout<<"It works";
else
cout<<"It does not work";
puts (buffer);
system("pause");
return 0;
}
}
|
When i have it display the variable date it displays "317."
Thank you for your help
Read the man page for strftime() and pay close attention to what it says about the return value.
Topic archived. No new replies allowed.