|
Hi,
I am writting the Huffman code algorithm now, I have built the huffman tree and stored the
corresponding binary string for each character ( 0-255)into a string array named arr_code, and got a list of binary string for the input file. my question is how can I transfer the binary string into
bit size then get it compressed?
Thanks!
|
|
|
|
|
I would pad the string with zeros up to length which can be divided by 8. And then I would read each time 8 characters and convert it into byte let's say by multipling already calculated part and adding value of a new bit character or by using << operator.
I hope this helps
DavidR
|
|
|
|
|
Thanks so much for your reply. I already finished this program last week. Now I am reading the "rice coding" algorithm if I have any question, I will post the question here. Thank you again!
JJ
|
|
|
|
|
I am just beginning to get into designing (hand-coding) forms with .Net using C++. I am trying to write a very simple application that has buttons on it and draws a black ball every 10 milliseconds that bounces around the screen which I plan to use to learn more about programming in .Net and as a reference for future programs. I placed every function and variable in a single class (except the main() function) that extends the Form class. I placed a call to Invalidate(), Update(), and Sleep(10) (in that order) in an idle function which I then used as the function to handle the Application Class's Idle event. The program does draw the black ball properly and does call the idle function but it only calls it after another event occures (such as when the mouse is moved over the form). I was wondering whether anyone could either tell me a way to fix this problem so that the black ball is drawn and moved every 10 milliseconds or provide me with a better way to do this. Any help on this would be greatly appriciated.
|
|
|
|
|
You could use a high resolution timer to drive the animation if you have hardware that supports it. Otherwise you could use a secondary thread that calls ::Sleep(10)
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
Thank you very much for your prompt response but as I said, I am just getting started with .Net so could you please clarify exactly how I would do this. Thanks in advance for any help on this subject.
|
|
|
|
|
|
Thanks for the information and I tried implementing it in the paint event handler as shown below:
<br />
void formOn_Paint(Object* sender, PaintEventArgs* e)<br />
{<br />
...
Invalidate();
Update();
System::Threading::Thread::Sleep(10); Sleep for 10 milliseconds.<br />
}<br />
Unfortunately, this code makes the program run extremely sluggishly and I have a new computer with a Pentium 4 so I really doubt it is the hardware. I used to have this code done in the application's idle handler (the drawing and moving of the black ball was still handled in the Form's paint event handler) as shown below:
<br />
void onIdle(Object* sender, EventArgs* e)<br />
{<br />
Invalidate();<br />
Update();<br />
System::Threading::Thread::Sleep(10);<br />
}<br />
Both of these functions are members of the class that is used as the parameter to the Run() function of the Application class so the keyword 'this' is implied when referring to the functions Invalidate() and Update().
Thanks in advance for any help you can provide me with on this subject.
|
|
|
|
|
>> you could use a secondary thread that calls ::Sleep(10)
You are calling sleep in the primary or UI thread. That is NOT a secondary thread and it is just not going to work very well.
-pete
|
|
|
|
|
Thank you very much for your help, that solved my problem.
|
|
|
|
|
i need to know what the nFolder variable for the value "56" is in the function SHGetFolderPath
HRESULT SHGetFolderPath( HWND hwndOwner,
int nFolder,
HANDLE hToken,
DWORD dwFlags,
LPTSTR pszPath
);
i browsed msdn, but there was no variable with such value,
pls help
thanks in advance
|
|
|
|
|
from ShlObj.h
#define CSIDL_RESOURCES 0x0038 // Resource Direcotry
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
my problem is disassembling managed c++ assemblies, so that when i try to re-compile the IL i don't get errors for functions, containing 'modopt' in their name.
If you can, please tell me how to disassemble such .net assemblies.
Thanks in advance,
Stan
|
|
|
|
|
Do you have a code sample that reproduces the problem? It sounds like a possible ildasm bug.
Matt
Visual C++ FE
|
|
|
|
|
the assembly is just a managed c++ dll. when i disasemble it using ildasm, and (try) to re-assemble it with ilasm, the error functions' names both have 'modopt' and double dots.
i do think it's bug, too.
|
|
|
|
|
Anything special about the functions that error? I'll check the bugbase.
Matt
|
|
|
|
|
well, i think some of the functions are native, and that's the prob
|
|
|
|
|
Hi friends i am new to c++ and also in the forum this question is my
experiment .Now problem is that , i want to change the while loop to
the nested for loop.
The program's description is as follows :-
Writ a program for a Match stick game between the computer and user .
Program should ensure that the computer always wins .
Rules for the Game are as follows:-
-There are 21 match sticks.
-The computer asks the player to pick 1, 2 ,3, or 4 match sticks .
-After the person picks , the computer does its picking .
-However is forced to pickup the last match stick looses the game .
The programs code is as under
/*Match Stick Game */
# include <stdio.h>
# include<conio.h>
void main ()
{
int m = 21,p,c;
clrscr();
while(1)
{
printf("\n\nNo.of matches left = %d",m);
printf("\npickup 1,2,3,or 4matches");
scanf("%d",&p");
if(p>4||p< 1)
continue;
m = m -p;
printf("\n\nNo. of matches picked up %d",c);
m =m-c;
if(m== 1)
{
printf ("\n\nNumber of matches left %d" ,m);
printf("\nYou lost hte Game !!");
break;
}
}
printf("\n\n\n\n\nPress any key to Exit...");
getch();
}
|
|
|
|
|
This sounds like homework to me
----------
int Value;<br />
<br />
for (int i = 21; i > 0; i=i)<br />
{<br />
Console::WriteLine("Pick 1,2,3 or 4: ");<br />
Value = Console::Read();<br />
<br />
if (Value <= 4 && Value >= 1)<br />
i = i - Value;<br />
else<br />
Console::WriteLine("Not a valid choice");<br />
<br />
if (i <= 0 )<br />
Console::WriteLine("Game over");<br />
}<br />
<br />
<br />
Console::WriteLine("Press enter to continue");<br />
Console::Read();
|
|
|
|
|
i am having issues while writing a file renamer program using borland c++. The problem is I can not replace non-unicode char to the unicode ones, for example i (not i) borland doesnt even let me to declare non-unicode chars.
If somebody has a clue or exprienced this before, please let me know.
Thnx...
Ilker TANLI
www.tanli.net
|
|
|
|
|
Hey Guys,
I've been looking at things around the Internet and i'm seeing this:
String* s = S"Hello World!";
the 'S' that precedes the string, what does that do? Is it the same as the @ modifier in C#?
Thanks,
Adam
-- Adam
"If you can't beat your computer in chess, try kickboxing"
|
|
|
|
|
|
I am in a migration project of conversion of COM components written in VC ++ to either Managed VC++ or C#.
Can anyone suggest me how to proceed with this.
Client wants to the development team to use some migration tool and convert it and after that rectify some minor errors and modifications.
I tried open the VC++ project in the MS Visual Studio.Net, but when I tried to build, it didn't worked out giving multiple errors for the header files.
Please suggest as I need to give some solution at the earliest.
|
|
|
|
|
If the design was done properly it should be a simple job to remove the COM layer and replace it with a Managed class or multiple classes that expose the native C++ classe(s) of the project.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
Hi,
how can i show an existing image in a c++ window. I mean i want my code to open a window and display an existing image in that window.
In a future work i will try to show an image sequence in that window.
For example, i have image001.bmp, image002.bmp,.. image016.bmp.
I want to open a window and display the images as a slide show in that window. Maybe going to the next image can be assigned to pressing a key on the keyboard. Or maybe a time feature could be used. I mean, in the window, existing images will be displayed each 0.5 seconds with the same order in the sequence.
Could someone help me with an explanatory piece of code?
Thank you ...
|
|
|
|