Click here to Skip to main content
15,915,703 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionUsing MS Excel in VC++ Pin
QSMZ12-Jul-10 20:39
QSMZ12-Jul-10 20:39 
AnswerRe: Using MS Excel in VC++ Pin
Cedric Moonen12-Jul-10 21:30
Cedric Moonen12-Jul-10 21:30 
AnswerRe: Using MS Excel in VC++ Pin
Roger Stoltz13-Jul-10 0:08
Roger Stoltz13-Jul-10 0:08 
AnswerRe: Using MS Excel in VC++ Pin
Sameerkumar Namdeo13-Jul-10 0:31
Sameerkumar Namdeo13-Jul-10 0:31 
AnswerRe: Using MS Excel in VC++ Pin
SnowHow13-Jul-10 10:39
SnowHow13-Jul-10 10:39 
Questiongetting day of week Pin
zon_cpp12-Jul-10 19:35
zon_cpp12-Jul-10 19:35 
AnswerRe: getting day of week Pin
CPallini12-Jul-10 21:27
mveCPallini12-Jul-10 21:27 
AnswerRe: getting day of week Pin
Aescleal12-Jul-10 21:37
Aescleal12-Jul-10 21:37 
I can't see what's wrong with your code (but there could be something in there, it's a bit convoluted) but this works on my compiler and uses the same function calls:

std::tm t = { 0, 0, 12, 13, 6, 110 };
std::time_t int_rep( std::mktime( &t ) );
t = *std::localtime( &int_rep );
std::cout << std::asctime( &t ) << std::endl;


It's a bit disgusting but seems to get the job done. I'd be tempted to wrap it up in a function though:

int day_of_week( int day, int month, int year )
{
	std::tm t = { 0, 0, 12, day, month - 1, year - 1900 };
	std::time_t gratuitous_l_value( std::mktime( &t ) );
	return std::localtime( &gratuitous_l_value )->tm_wday;
}


If you're programming in C and not C++ just remove the std:: everywhere, include time.h and not ctime and convert the constructor style initialisations to = and it'll probably work.

Cheers,

Ash
QuestionBorland C++ to Visual C++ conversion Pin
coder21k12-Jul-10 19:22
coder21k12-Jul-10 19:22 
AnswerRe: Borland C++ to Visual C++ conversion Pin
hypheni12-Jul-10 21:18
hypheni12-Jul-10 21:18 
AnswerRe: Borland C++ to Visual C++ conversion [modified] Pin
Rolf Kristensen13-Jul-10 6:07
Rolf Kristensen13-Jul-10 6:07 
QuestionCustom DateTime Control Pin
AbhiHcl12-Jul-10 19:08
AbhiHcl12-Jul-10 19:08 
QuestionCan i convert from CStrin to double Pin
raju_shiva12-Jul-10 19:05
raju_shiva12-Jul-10 19:05 
AnswerRe: Can i convert from CStrin to double Pin
«_Superman_»12-Jul-10 19:49
professional«_Superman_»12-Jul-10 19:49 
AnswerRe: Can i convert from CStrin to double Pin
Aescleal12-Jul-10 21:57
Aescleal12-Jul-10 21:57 
QuestionTerminateProcess doesn't work as expected on Windows XP Pin
pubis12-Jul-10 13:18
pubis12-Jul-10 13:18 
AnswerRe: TerminateProcess doesn't work as expected on Windows XP Pin
El Corazon12-Jul-10 14:40
El Corazon12-Jul-10 14:40 
AnswerRe: TerminateProcess doesn't work as expected on Windows XP Pin
«_Superman_»12-Jul-10 16:27
professional«_Superman_»12-Jul-10 16:27 
GeneralRe: TerminateProcess doesn't work as expected on Windows XP Pin
pubis13-Jul-10 4:32
pubis13-Jul-10 4:32 
GeneralRe: TerminateProcess doesn't work as expected on Windows XP Pin
«_Superman_»13-Jul-10 5:43
professional«_Superman_»13-Jul-10 5:43 
QuestionMFC BOOK Pin
mdocvc12-Jul-10 8:41
mdocvc12-Jul-10 8:41 
QuestionRe: MFC BOOK Pin
Maximilien12-Jul-10 8:46
Maximilien12-Jul-10 8:46 
JokeRe: MFC BOOK Pin
Richard MacCutchan12-Jul-10 8:57
mveRichard MacCutchan12-Jul-10 8:57 
AnswerRe: MFC BOOK Pin
Hristo-Bojilov12-Jul-10 9:08
Hristo-Bojilov12-Jul-10 9:08 
GeneralRe: MFC BOOK Pin
Alan Balkany15-Jul-10 4:13
Alan Balkany15-Jul-10 4:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.