|
That seemed to have done the trick thanks
|
|
|
|
|
is there an x64 version of HTMLHELP.LIB ?
i'm trying to migrate a project to x64 and i'm getting an unresolved external on HtemlHelpA.
::HtmlHelpA(NULL, path, HH_DISPLAY_TOPIC, 0);
the function is defined in htmlhelp.h, but it doesn't seem to be in the .LIB .
|
|
|
|
|
Isn't this a repost?
Regards,
--Perspx
"The Blue Screen of Death, also known as The Blue Screen of Doom, the "Blue Screen of Fun", "Phatul Exception: The WRECKening" and "Windows Vista", is a multi award-winning game first developed in 1995 by Microsoft" - Uncyclopedia
Introduction to Object-Oriented JavaScript
|
|
|
|
|
|
I am working on a StringPool class. I'm trying to find the fastest way to look up a wchar_t* in an associative container. The current way I do this is to hash the string, and look up the hash value in the container. If it's not there, then add a new entry for it.
the code looks something like this:
size_t StringPool::find( const wchar_t* str, size_t length )
{
size_t result = NoEntry;
size_t hashID = hash(str,length);
StringMapRangeT found = stringMap_.equal_range( hashID );
StringMapIter current = found.first;
size_t rangeCount = 0;
while ( current != found.second ) {
rangeCount ++;
++current;
}
current = found.first;
if ( rangeCount == 1 ) {
size_t idx = current->second;
if ( idx < stringEntries_.size() ) {
const StrEntry& entry = stringEntries_[idx];
if ( entry.length == length ) {
result = idx;
}
}
}
else {
while ( current != found.second ) {
size_t idx = current->second;
if ( idx < stringEntries_.size() ) {
const StrEntry& entry = stringEntries_[idx];
if ( entry.length == length ) {
if ( 0 == ::wmemcmp( entry.str, str, length ) ) {
result = idx;
break;
}
}
}
++current ;
}
}
return result;
}
where StrEntry is just a struct that holds info about a string instance, like the string pointer, the length, etc.
stringMap_ is a multimap defined like so: std::multimap<size_t,size_t>
The multimap is the slowest (as far as I can tell) element here. Is there a better container to use? This is particularly true when a new string is added, and I first see if it exists or not (which is where the above code is called), and if not, then the hash id is inserted into the stringMap_. The insert is (not surprisingly) kind of expensive, so I'm wondering if there's a better approach or container to use.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
VCF Blog
|
|
|
|
|
Sorry, I didn't look in detail at your code, but maybe a Trie[^] structure is what you need here.
|
|
|
|
|
I'm struggling with some USB devices that work like a serial devices.
The driver used is UsbSer.sys.
So I register for device notifications and in OnDeviceChange() I get the "filename" for the device so I can open it with ::CreateFile() .
I now need a way to get the vendor and product ids from the device, preferably by using ::DeviceIoControl() or the Setup API.
Actually it's a composite device so it registers as a few different devices.
This means I can access it using different drivers, using different "filenames", but it should be used as a serial device. Even if I got the vendor id by using another device class I haven't found a way to map that device to the serial driver for the same device.
Is there some I/O control code or a neat method using the setup API I've overlooked, I would be most grateful to be pointed in the right direction.
Previously the "filename" has been parsed since it seemed to be built using the vendor and product ids, but this method breaks when the device presents itself as a composite device. So I assume using the registry is not the way to do it.
Ideas anyone?
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Hey all,
I've got this really annoying problem I just can't solve - I'm trying to print the elements of my array of strings, but I can't make it, I've tried several different ways.
Here's my code, which won't compile:
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
string a[]={"a", "b", "c", "d", "e"};
cout << a[3];
return 0;
}</iostream>
I've been googling around for quite a while now and this code looks so right to me.
And one other thing; how can i create a string from several elements of this array?
Thx
/Joplinazz
|
|
|
|
|
why doesn't it compile ?
any compiler/linker errors ?
|
|
|
|
|
Well, here's the huge description of the error I'm getting:
c:\andreas\programmering\cpp\arraytesting\arraytesting\arraytesting.cpp(11) : error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)
c:\program\microsoft visual studio 9.0\vc\include\ostream(653): could be 'std::basic_ostream<_Elem,_Traits> &std::operator <<<char,std::char_traits><char>>(std::basic_ostream<_Elem,_Traits> &,const char *)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(700): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<char,std::char_traits><char>>(std::basic_ostream<_Elem,_Traits> &,char)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(738): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits xmlns:std="#unknown"><char>>(std::basic_ostream<_Elem,_Traits> &,const char *)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(785): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits><char>>(std::basic_ostream<_Elem,_Traits> &,char)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(909): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits><char>>(std::basic_ostream<_Elem,_Traits> &,const signed char *)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(916): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits><char>>(std::basic_ostream<_Elem,_Traits> &,signed char)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(923): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits><char>>(std::basic_ostream<_Elem,_Traits> &,const unsigned char *)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(930): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits><char>>(std::basic_ostream<_Elem,_Traits> &,unsigned char)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(170): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::basic_ostream<_Elem,_Traits> &(__cdecl *)(std::basic_ostream<_Elem,_Traits> &))'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(176): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::basic_ios<_Elem,_Traits> &(__cdecl *)(std::basic_ios<_Elem,_Traits> &))'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(183): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::ios_base &(__cdecl *)(std::ios_base &))'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(190): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::_Bool)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(210): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(short)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(243): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(unsigned short)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(263): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(__w64 int)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(288): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(__w64 unsigned int)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(308): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(long)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(328): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(__w64 unsigned long)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(349): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(__int64)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(369): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(unsigned __int64)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(390): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(float)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(410): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(double)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(430): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(long double)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(450): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(const void *)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(470): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::basic_streambuf<_Elem,_Traits> *)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
while trying to match the argument list '(std::ostream, std::string)'
Build log was saved at "file://c:\Andreas\Programmering\Cpp\ArrayTesting\ArrayTesting\Debug\BuildLog.htm"
ArrayTesting - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped
</char></char></char></char></char></char></char></char></char></char></char></char></char></char></char></char></char></char></char></std::char_traits></char></char></std::char_traits></char></char></std::char_traits></char></char></std::char_traits></char></char></std::char_traits></char></char></std::char_traits></char></char></char></char>
I'm using Visual C++ 2008.
/Joplinazz
|
|
|
|
|
Damn, only few errors would have suffice !!!
moreover, your lines are too long to fix the <pre> tag...
did you correctly included the header needed ?
#include <string>
#include <iostream>
also, try to use std::string::c_str() to print the string out:
cout << (a[3]).c_str();
|
|
|
|
|
Haha, yeah you're right..
Thanks a lot for your help, the headers were the problem.
I didn't use #include <string> - Strange error(to me, hehe).
/Joplinazz
|
|
|
|
|
Well, looks good to me.
I suppose you have included iostream. It doesn't show since you haven't used the small < and > wonders below the text input frame when you posted your message.
Joplinazz wrote: And one other thing; how can i create a string from several elements of this array?
Try this:
#include <sstream>
int main()
{
std::string Strings[] = { "a", "b", "c" };
std::ostringstream stm;
stm << Strings[2] << Strings[0] << Strings[1] << std::endl;
std::cout << stm.str().c_str();
} You'll get "cab" written to cout.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Thanks Roger, I managed to make it work this way:
myString = a[0] + a[1];
/Joplinazz
|
|
|
|
|
How do I create a UI thread capable of showing CDialog? I'm currently using AfxBeginThread for my working thread but also want to be able to display things like CDialog.DoModal from inside the worker thread. Do I have to make it a UI thread? How do I go about it?
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
|
The second version wants a subclassed CWinThread, but I'm not sure where exactly to place my code in it. May be in InitInstance. Any suggestions?
I already have the worker thread and the code for it, I need to know what to change to make showing modal CDialogs possible.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
The second link shows common CWinThread overrides
and what those overrides should do.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Sorry, I didn't notice it. Thanks.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Hi.I'm using visual c++ 9.0.
I want to do something like this:
string name = get_name();
string filename = name+("text.dat");
ifstream infile_file;
infile_file.open(filename);
(code)
(...)
I'm doing something wrong... or I am missing something.
Here is the error:
error C2664: 'void std::basic_ifstream<_Elem,_Traits>::open(const wchar_t *,std::ios_base::openmode,int)' : cannot convert parameter 1 from 'std::string' to 'const wchar_t *'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
Thanks.
"Failure is always an option."
|
|
|
|
|
this is because you're building your appblication in UNICODE most probably...
try removing the declaration of that macro and rebuild.
forget that. std::string::c_str() is the way to go
modified on Wednesday, September 3, 2008 11:05 AM
|
|
|
|
|
I did remove the declaration in progect properties.. but didn't work...
But thanks anyway for your help.
"Failure is always an option."
|
|
|
|
|
yeah, after reading David's Answer, I figured out my mistake...
|
|
|
|
|
FrankMookie wrote: infile_file.open(filename);
Try:
infile_file.open(filename.c_str());
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
it worked just fine withinfile_file.open(filename.c_str()); . Thanks alot!
"Failure is always an option."
|
|
|
|
|