|
hi,Richard ,thank you for your attention,but i can't find a way which create or save as an icon
|
|
|
|
|
If you do not have Visual Studio then you need to use Google to search for a free program, or code your own. MVP 2010 - are they mad?
|
|
|
|
|
|
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;
}
|
|
|
|
|
I don't know enough about fstream - though it looks as though it's performance may vary between implementations.
Just ran your code through MinGW 3.4.5, and I see a very different picture to the one you describe.
Over here, your code timings are:
fstream: 78
fwrite: 109
write: 3391
I know iostream & fstream increase program size considerably, (read several 100k) and would have expected
fstream to be second, in terms of performance, though this clearly appears not to be the case.
|
|
|
|
|
Hi All
How can i change tab control color?I try to change through OnCtlColor function but no change in control.
|
|
|
|
|
Member 6864839 wrote: Hi All
How can i change tab control color ?I try to change through OnCtlColor function but no change in control
Gee, I dunno - It's a long shot, but you could always try submitting the text in red to google and clicking on the second link. It's here, provided for your laziness convenience.
How To Change the Background Color of a Tab Control[^]
|
|
|
|
|
In the two forms of vector::erase:
iterator erase(iterator position);
iterator erase(iterator first, iterator last);
can the 'iterator' mentioned be a vector::const_iterator, vector::reverse_iterator, or vector::const_reverse_iterator as well as a vector::iterator ?Edward Diener
|
|
|
|
|
No - iterator and only iterator . Remember that the type iterator isn't a template parameter - this isn't an algorithm, it's a method of vector .Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
CodeProject MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
Why would not reverse_iterator be just as theoretically valid as iterator for the erase function ? The same goes for the insert function. Edward Diener
|
|
|
|
|
It's probably because the operations on vector are those defined for 'containers' - and not all containers (for example singly linked lists) can have reverse iterators. Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
CodeProject MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
Edward Diener wrote: The same goes for the insert function.
er... no!
The insert function takes iterators as template parameters, meaning "whatever iterator types indicating a source range you've to copy from".
The erase function, in contrast, requires iterators from the same container you're erasing.
They cannot be "const" (because the container isn't const, since you're modifying it) nor "reverse" (because of the way elements in vectors are managed).
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
Hi,
I'd like to know,,.
1) when I create my Dialog from CDialog class, why my Dialog does not have Destrucotr?
I want to free some heap memory I used in program,,, when I write writ memory clear code?
2) class CMyView
{
//from somewhre(such as thread) can
FuncA() {A();}
//from somewhre(such as thread) can send Window Message via (SendMessage())
FuncB(WPAAM w, LPARAM l) { A();}
A(){ print("A() called"); }
}
I'd like to know How they are diffrent?
when from calling function and calling via SendMessage()?
Have a day.
|
|
|
|
|
rambojanggoon wrote: why my Dialog does not have Destrucotr?
Did you code one?
rambojanggoon wrote: How they are diffrent?
when from calling function and calling via SendMessage()?
They are not different, you call the same function in both case.MVP 2010 - are they mad?
|
|
|
|
|
I am wondering why the second and third declarations below generate errors:
const double** const example1 = new const double*[5];
const double** const example2 = new double*[5];
const double** const example3(new const double*[5]);
void SomeFunction(const double* const * const);
SomeFunction(example3); Why is the compiler interpreting example3 as a function pointer? Why can't a 'double**' be implicitly cast to a 'const double** const'? Thanks,Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
The C2059 error is a compiler problem. It sees const double** const example3( and thinks it's a function declaration - and you can't have the new keyword in a function declaration. g++ compiles that declaration with no problem.
As for the rest…that's the rules of C++. If you really want to do it, you'll have to use an explicit cast.Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
CodeProject MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
Hi Everyone,
I am Creating one application with the VC++(MFC).
I am using windows XP-32 and VS 2008.
I am trying to connect to the phone Nokia 6610 with the serial COM Port.
I want to set the At Commands on this phone.
I want to get he event when any new msg come on the phone.
I am using boost library to connect the phone.
When I am using
boost::asio::io_service io_service;
boost::asio::ip::tcp::resolver resolver(io_service);
boost::asio::ip::tcp::resolver::query query("localhost", "20");
boost::asio::ip::tcp::resolver::iterator iterator = resolver.resolve(query);
boost::asio::ip::tcp::socket mSocket(io_service);
boost::asio::ip::tcp::endpoint endpoint(boost::asio::ip::address::from_string("1.2.3.4"), 12345);
mSocket.connect(*iterator);
I am getting the error Exeption at the connect method.
Please help me Or give me some hint Or get the link of the examples of such examples.With Regards,
Mitul Golakiya.
E-Mail : mitulgolakiya@yahoo.com
|
|
|
|
|
To resolve this problem you would better asc library vendor/author.Here is nice tutorial how to connect with serial ports in MFC based on simple win32 wrapper.Life is a stage and we are all actors!
modified on Saturday, February 6, 2010 5:14 PM
|
|
|
|
|
Mitul Golakiya wrote: I am getting the error Exeption at the connect method.
Well if you don't tell us what the Exception is, we cannot guess!MVP 2010 - are they mad?
|
|
|
|
|
Hi,
Below is the code for which i get different outputs when compiled in vc6 and vs2008.
Why is it happening? Any comments will be helpful.
double x2 = 4294967036;
int i = 0;
i=(int)x2;
CString str;
str.Format(_T("%d == %d"),i,INT_MAX);
AfxMessageBox(str);
Output in vc6: -260 == 2147483647
Output in VS2008: -2147483648 == 2147483647
I can see that as the value is greater than max limit, its trying to display the max value. But I guess the typecasting is not exactly working in VS2008. How to make the typecasting work?Priya Sundar
|
|
|
|
|
Priya_Sundar wrote: But I guess the typecasting is not exactly working in VS2008.
It looks as though VS6 is the one that is not working. If you have a signed integer with a value of 231, every time you increment it, the value will get smaller until it reaches -231.
Priya_Sundar wrote: How to make the typecasting work?
What are you trying to do?"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Basically I have huge old code with the way vc6 works. We then migrated it to vs2008. So the same old code seems to produce different results.
So we are looking for some solution.Priya Sundar
|
|
|
|
|
|
|
I'm getting this message when I build my project -
Linking...<br />
MyThread.obj : error LNK2001: unresolved external symbol "public: void __thiscall CMyThread::MyMessageHandler(unsigned int,long)" (?MyMessageHandler@CMyThread@@QAEXIJ@Z)<br />
E:\Stuff\Manmohan\Visual C++\IPM\Debug\IPM.exe : fatal error LNK1120: 1 unresolved externals
My code is here :-
.
.
.
#define WM_MYMESSAGE (WM_USER+1)
---------------------------------------------
#pragma once
class CMyThread : public CWinThread
{
DECLARE_DYNCREATE(CMyThread)
public:
CMyThread();
virtual ~CMyThread();
public:
afx_msg void MyMessageHandler(WPARAM, LPARAM);
virtual BOOL InitInstance();
virtual int ExitInstance();
protected:
DECLARE_MESSAGE_MAP()
};
-----------------------------------------
.
.
.
afx_msg void MyMessageHandler(WPARAM, LPARAM)
{
}
BEGIN_MESSAGE_MAP(CMyThread, CWinThread)
ON_THREAD_MESSAGE(WM_MYMESSAGE, MyMessageHandler)
END_MESSAGE_MAP()
My project is MFC dialog based.Future Lies in Present.
Manmohan Bishnoi
|
|
|
|