|
Hi,
I found an algorithm which was used for an int array.
I modified it so i can use it for my char array.
It works good but not as how i wanted it to work.
This is how it looks like right now:
<br />
void permute(char *v, const int start, const int n);<br />
void print(const char *v, const int size);<br />
<br />
int main(int argc, char* argv[])<br />
{<br />
char v[] = {'a', 'v', 'e', 'd', 'k', 'u', 'r', 'n', 'e'};<br />
permute(v, 0, sizeof(v)/sizeof(char));<br />
<br />
system("pause");<br />
return 0;<br />
}<br />
<br />
void print(const char *v, const int size)<br />
{<br />
if (v != 0) <br />
{<br />
for (int i = 0; i < size; i++) <br />
{<br />
cout << v[i];<br />
}<br />
cout << endl;<br />
}<br />
}
<br />
<br />
void permute(char *v, const int start, const int n)<br />
{ <br />
if (start == n-1)<br />
print(v, n);<br />
<br />
else <br />
{<br />
for (int i = start; i < n; i++) <br />
{<br />
char tmp = v[i];<br />
<br />
v[i] = v[start];<br />
v[start] = tmp;<br />
permute(v, start+1, n);<br />
v[start] = v[i];<br />
v[i] = tmp;<br />
}<br />
}<br />
}<br />
It's making letter combinations with only all letters.
It should actually start with 2 letters and then continue until all 9 letter combinations are found.
|
|
|
|
|
Why don't you do something clever like computing the hash of your letter combinations / words, but do it in a way that is independent of letter order. The hash value of the jumbled combination would match the hash value of the unjumbled word. Then you would only have to search the (hopefully) few words with matching hash values.
One way you could do this would be to use a standard hash routine, but sort the letters in the word into alphabetical order prior to hashing them.
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
How could I get the Instance Handle from another Process ID?
Maybe the Process has no any windows, so I can't use the GetWindowLong API.
And I know nothing about the Module Name of the third Process, so I can't use the GetModuleHandle API,too.
So,how could I get the Instance Handle from another Process ID?Or how could I get the Module Name of the third Process,that I can use the GetModuleHandle API for it?
|
|
|
|
|
Billypon wrote: How could I get the Instance Handle from another Process ID?
Use OpenProcess API.
HANDLE hProcHandle = ::OpenProcess( PROCESS_ALL_ACCESS, FALSE, dwAnotherProcessID );
ASSERT( hProcHandle );
The first parameter specifies type of access needed. PROCESS_ALL_ACCESS won't always work.
The type of action that you want to take on the remote process will determine the access needed. For eg: to terminate a process you will need PROCESS_TERMINATE access right or for ReadProcessMemory and WriteProcessMemory PROCESS_VM_**** rights.
It's safe to have the SeDebugPrivilege enabled for your application if would like to do some advanced stuff with the other process.
You might be interested to look up this article -> http://www.codeproject.com/useritems/processviewer.asp[^]
|
|
|
|
|
Hello All
What are the good books / internet links available for learning STL ? Can anybody suggest.
Thanx.
|
|
|
|
|
Try C++ The Complete reference - By Herbert Schild
STL you will find many samples in MSDN also..
you can check online MSDN.
|
|
|
|
|
A reference book you absolutely want is
Nicolai M. Josuttis, "The C++ Standard Library - A Tutorial and Reference", Addison-Wesley
As a Link, I recommend the SGI pages[^]
Failure is not an option - it's built right in.
|
|
|
|
|
My favorite is Christian Graus[^] Check in the STL part of the link for his article on STLs.
|
|
|
|
|
Hi everybody,
i realized already a drag&drop of text from out a CListCtrl into a MS Word Document.
I used COleDropSource, COleDataSource, CSharedFile and CArchive
How does it work with bitmap?
Copy a bitmap into the clipboard via OpenClipboard & SetClipboardData works fine.
But it stores only the bitmap into the clipboard. No Drag&Drop possibility.
So i need to work with COleDropSource and COleDataSource, right?
Does is work via .WriteObject or WriteClass ?
Big thanks for help
|
|
|
|
|
Why does the below code throw exception in parent class?
#include <iostream><br />
<br />
using namespace std;<br />
<br />
class A<br />
{<br />
};<br />
<br />
class B : public A<br />
{<br />
};<br />
<br />
int main()<br />
{<br />
B b;<br />
<br />
try<br />
{<br />
throw b;<br />
}<br />
catch (A& ea)<br />
{<br />
cout << "Caught an instance of A" << endl;<br />
}<br />
catch (B& eb)<br />
{<br />
cout << "Caught an instance of B" << endl;<br />
}<br />
return 0;<br />
}
|
|
|
|
|
if you are using VC++ IDE (dont know about other ide's )you will get some warning when you compile.
that warning will make it clear why it is gettign thrown in parent class.
Try changing the sequence of catch block you will undestand the reason yourself.
|
|
|
|
|
As an additional note, you shoud aim towards catching constant references.
Failure is not an option - it's built right in.
|
|
|
|
|
the rule is: when you are catching exceptions you need to order the catch clauses from most derived to base!!!
simply change the order of the catch handlers searching for exception b first then a!!!
since class b is derived from class a it makes sense what you are seeing.
Yours Truly, The One and Only!
|
|
|
|
|
But why is it so? Is it a rule or is there some inbuild logic in doing so?
|
|
|
|
|
it seems you don't understand C++ basic OOP principles?
simple answer: your class b IS A class a, now do you know why?;P
Yours Truly, The One and Only!
|
|
|
|
|
There is a button inside a dialog say D1.
When we click on it, it should show a list box below it.
Here there is a problem.
If the dialog D1 is small then the list box appears only till the bottom of the dialog.Rest of the list box is not shown. This is because the list box is a child of the button or dialog D1.
How can we show the whole list box even when the bottom of the list box is greater than the bottom of the dialog?
Can we have a popup listbox just like popup dialog?
|
|
|
|
|
You can resize your Dialog to add space to be filled with the listbox.
Or you can add the listbox in the resource editor to your diaog D1, but when D1 is shown, you resize it to not show the lower part with the Listbox.
Fore these things, please refer to this article[^].
Failure is not an option - it's built right in.
|
|
|
|
|
Thanks a lot for your concern.
But i don't want to change the dialog size. The dialog size should be fixed.
The button and Listbox together should work similar to a combo box.
So the Listbox here should extend below the dialog as in the case of listbox of a combo box.
I am planning put the list box inside a popup dialog and invoke it on click of the button. But then i had to use a dialog resource only to show the listbox.
Please help me out if there is any alternative.
once again thanks a lot.
|
|
|
|
|
harsha u wrote: The button and Listbox together should work similar to a combo box.
Hmmm - OK.
In that case, I would think you should look up how the various combobox-articles[^] here on code project manage the drawing of their drop-down box. And learn how they do it.
This probably involves creating a borderless window, and maybe the listbox-ctrl itself is enough for that. Or maybe you need to draw a window yourself and place the listbox-ctrl on top of it.
But I never did a thing like that.
Failure is not an option - it's built right in.
|
|
|
|
|
harsha u wrote: How can we show the whole list box even when the bottom of the list box is greater than the bottom of the dialog?
Yes make this list box a child of the desktop window but read this[^] before proceeding.
You will also need SetCapture and ReleaseCapture to close your listbox to when clicked outside listbox area.
|
|
|
|
|
Hai...
i am developing application like chat. In this i have added font styles like(bold,Italic,underline and size.) if i chose some of the styles and typing in my richeditbox so the respective styles font s are coming. now i want to send the text with same style fonts in chat history richedit box.
but now it is sending without styles only.
how to do that...
|
|
|
|
|
I can't give you a solution but maybe an idea. Insteads of sending the message from richedit, send a struct. The struct contains a BYTE or WORD (depending on size) with flasgs of bold, underscored and so on, and the other member the message itself. Then on the other client you recieve the packet, create the font according to flags and show the message, freeing resources.
All this is because I'm not sure if the parameters of the CFont are sent, it should but...
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
|
I want to make a particular color of a Modeless Child dialog transparent.
I searched the net but everywhere the solution was for a WS_POPUP style child dialog. If i change the style of the dialog to WS_CHILD, then the transparency alogrithm stops working.
Can anybody help me with this issue...
Regards
Meenu
|
|
|
|
|
Use SetLayeredWindowAttributes.
|
|
|
|