Click here to Skip to main content
15,897,315 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: usb driver to my simple hardware Pin
Iain Clarke, Warrior Programmer7-Feb-10 21:06
Iain Clarke, Warrior Programmer7-Feb-10 21:06 
AnswerRe: usb driver to my simple hardware Pin
transoft8-Feb-10 4:37
transoft8-Feb-10 4:37 
Questionhow to create an icon file? Pin
kiluar6-Feb-10 21:44
kiluar6-Feb-10 21:44 
AnswerRe: how to create an icon file? Pin
Richard MacCutchan6-Feb-10 21:55
mveRichard MacCutchan6-Feb-10 21:55 
GeneralRe: how to create an icon file? Pin
kiluar7-Feb-10 21:59
kiluar7-Feb-10 21:59 
GeneralRe: how to create an icon file? Pin
Richard MacCutchan7-Feb-10 22:09
mveRichard MacCutchan7-Feb-10 22:09 
AnswerRe: how to create an icon file? Pin
KingsGambit7-Feb-10 18:23
KingsGambit7-Feb-10 18:23 
QuestionFile writing performance comparing Pin
followait6-Feb-10 19:53
followait6-Feb-10 19:53 
Tested by the sample code below, the result:
1. write is much slower than the other two
2. fwrite is twice as fast as ofstream.write

I know write is not buffered, so it is much slower,
I think the performance of the other two should be close, but why not?

#define WIN32_LEAN_AND_MEAN

#include <stdio.h>
#include <tchar.h>
#include <io.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <assert.h>
#include <fstream>
#include <windows.h>

#pragma warning(disable : 4996)

int _tmain(int argc, _TCHAR* argv[])
{	
	const int buf_size = 1<<20;
	char * buf = new char[buf_size];
	FILE * f1 = fopen("d:/test1", "w");
	assert(f1);
	int f2 = open("d:/test2", _O_BINARY | _O_CREAT | _O_TRUNC | _O_WRONLY, _S_IWRITE);
	assert(f2!=-1);

	DWORD t;
	
	t = GetTickCount();	
	for (size_t i=0; i<buf_size; ++i)
		fwrite(buf+i, 1, 1, f1);
	fclose(f1);
	printf("count of ticks used: %d bytes\n", GetTickCount()-t);

	t = GetTickCount();
	for (int i=0; i<buf_size; ++i)
		write(f2, buf+i, 1);
	close(f2);
	printf("count of ticks used: %d\n", GetTickCount()-t);

	t = GetTickCount();
	std::ofstream ofs("d:/test3", std::ios_base::out | std::ios_base::binary | std::ios_base::trunc);
	for (int i=0; i<buf_size; ++i)
		ofs.write(buf+i, 1);
	ofs.close();
	printf("count of ticks used: %d", GetTickCount()-t);

	delete buf;

	getchar();
	return 0;
}

AnswerRe: File writing performance comparing Pin
enhzflep7-Feb-10 4:10
enhzflep7-Feb-10 4:10 
QuestionTab Control color Pin
Member 68648396-Feb-10 19:52
Member 68648396-Feb-10 19:52 
AnswerRe: Tab Control color Pin
enhzflep7-Feb-10 4:19
enhzflep7-Feb-10 4:19 
Questionvector:erase iterator requirements Pin
Edward Diener6-Feb-10 16:25
Edward Diener6-Feb-10 16:25 
AnswerRe: vector:erase iterator requirements Pin
Stuart Dootson7-Feb-10 1:17
professionalStuart Dootson7-Feb-10 1:17 
GeneralRe: vector:erase iterator requirements Pin
Edward Diener7-Feb-10 4:52
Edward Diener7-Feb-10 4:52 
GeneralRe: vector:erase iterator requirements Pin
Stuart Dootson7-Feb-10 5:12
professionalStuart Dootson7-Feb-10 5:12 
GeneralRe: vector:erase iterator requirements Pin
Emilio Garavaglia7-Feb-10 23:07
Emilio Garavaglia7-Feb-10 23:07 
Questionwhy myDiagl subclassed from CDialg don't have destructor? Pin
rambojanggoon6-Feb-10 14:38
rambojanggoon6-Feb-10 14:38 
AnswerRe: why myDiagl subclassed from CDialg don't have destructor? Pin
Richard MacCutchan6-Feb-10 21:50
mveRichard MacCutchan6-Feb-10 21:50 
QuestionInitializing pointer results in errors Pin
Skippums6-Feb-10 10:35
Skippums6-Feb-10 10:35 
AnswerRe: Initializing pointer results in errors Pin
Stuart Dootson6-Feb-10 14:09
professionalStuart Dootson6-Feb-10 14:09 
QuestionHow to Create a Connection with Phone serail COM Port ? Pin
Mitul Golakiya6-Feb-10 9:53
Mitul Golakiya6-Feb-10 9:53 
AnswerRe: How to Create a Connection with Phone serail COM Port ? [modified] Pin
Hristo-Bojilov6-Feb-10 10:39
Hristo-Bojilov6-Feb-10 10:39 
AnswerRe: How to Create a Connection with Phone serail COM Port ? Pin
Richard MacCutchan6-Feb-10 21:46
mveRichard MacCutchan6-Feb-10 21:46 
QuestionDifferent outputs in vc6 &amp; vs2008 with same code(typecasting). Help Pin
Priya_Sundar6-Feb-10 7:05
Priya_Sundar6-Feb-10 7:05 
AnswerRe: Different outputs in vc6 &amp;amp; vs2008 with same code(typecasting). Help Pin
David Crow6-Feb-10 13:34
David Crow6-Feb-10 13:34 

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.