c++

huffman encoding

hiii... I am trying to implement the huffman algorithm for compression.. for that I have to write bits of variable length to a file.. is there any datatype in c++ to store bits in a file???? i tried using bitset<8> but its size is 4 bytes..so i cant use it since i am implementing compression..please help.. ...

Call member function on each element in a container.

Hello, This question is a matter of style, since you can always write a for loop or something similar; however, is there a less obtrusive STL or BOOST equivalent to writing: for (container<type>::iterator iter = cointainer.begin(); iter != cointainer.end(); iter++) iter->func(); ? Something like (imagined) this: call_for...

Why buildtools like AutoTools?

Recently, I switched my development environment to LINUX from Windows. I have only used Visual Studio so far for C++ development. So many concepts like make, autotools are new to me. I have read GNU makefile documentation and got almost an idea about it. But I am kinda confused about autotools. AFAIK, makefiles are used to make the buil...

Knowing C++, how long does it take to learn Java?

I am a competent C++ developer. I understand and use polymorphism, templates, the STL, and I have a solid grasp of how streams work. For all practical purposes, I've done no Java development. I'm sure some of you were in a similar situation at one point when you had to learn Java. How long did it take you to become a competent Java p...

Win32 named pipes and remote clients

Can I access a named pipe on computer A from computer B given computer A's IP address? If so, what do I need to do to make this happen? ...

Which GUI framework is used by the "Spybot Search & Destroy" application?

I want to replicate the look and feel of Spybot Search & Destroy in my own applications. Is there a publicly-available framework, toolkit, or library to aid in this task? ...

Need some help reading file

Hi, I am having lots of troubles trying to read a file in C++. The main problem I'm having is reading properly the first line of the stream since it is different from all the other lines. A sample file would be: #Newbie 101|Exam 1|3 Person One|10 Person Two|20 Person Three|30 the first line starts with a # and declares the class nam...

How does 2 or more processes interact with the keyboard?

Hello. I have been thinking alot over keyboard handling. How does it work? I cant seem to google me to a good explaining. I know that a keyboard interrupt is made every time a key is pressed. The processor halts whatever it is processing and load the keyboard data from the keyboard buffer, storing it in a system level buffer. But what ha...

open source dev environment for C++: what's better?

I want to do some coding in my spare time, but the thing is, I don't want to spend the money on this. Would the following set of development tools be The Right Thing, or is there something I'm forgetting? Eclipse for C++ SVN for source control Qt for UI development (since it's C++, and I believe it's now opened by Nokia) hudson for co...

How do I call unmanaged C/C++ code from a C# ASP.NET webpage

I have an ASP.NET website that uses C# and I'd like to call functions from an unmanaged C/C++ DLL. How do I do it? ...

Initialization and Assignment

I have some 'legacy' code (which I can't change, but need to add on to) that looks something like this: template<typename T> T Foo(T& target) { //Assign to 'target', but never read from it before that. //Also, 'target' is going to be a POD-type. target = T(); return target; } int main() { float value = Foo(value);...

Calculating size of an array

Hi, I am using the following macro for calculating size of an array: #define G_N_ELEMENTS(arr) ((sizeof(arr))/(sizeof(arr[0]))) However I see a discrepancy in the value computed by it when I evaluate the size of an array in a function(incorrect value computed) as opposed to where the function is called(correct value computed). Code...

Concatenating strings

Hi all, I have a vector of string and I intend to join these strings into a single string, separated by a space. For example, if my vector contains the values: sample string for this example I want the output to be "sample string for this example". Need any of your input on what is the simplest way of achieving this? Thanks ...

Visual C++ error C2143: syntax error: missing ')' before 'constant'

I'm getting an error in Visual C++ that is giving me a really hard time. The error is error c2143 reading: syntax error: missing ')' before 'constant' My code line is: coefficient[i] = (1 - (2 * depth)) + ((t - floor( t + 0.5 ) + 1 ) 2 * depth); I have #include at the beginning of the file which should define the floor(double) func...

How can i estimate memory usage of stl::map?

For example, I have a std::map with known sizeof(A) and sizefo(B), while map has N entries inside. How would you estimate its memory usage? I'd say it's something like (sizeof(A) + sizeof(B)) * N * factor But what is the factor? Different formula maybe? Update: Maybe it's easier to ask for upper bound? ...

how to return two dimensional char array c++ ?

i ve created two dimensional array inside a function, i want to return that array, and pass it somewhere to other function.. char *createBoard( ){ char board[16][10]; int j =0;int i = 0; for(i=0; i<16;i++){ for( j=0;j<10;j++){ board[i][j]=(char)201; } } return board; } but this keeps giving m...

static class and singleton

Isn't a class with all static members/methods a kind of singleton design pattern? Is there any disadvantage in particular of having such classes? A detailed explanation would help. ...

Boost, sending files over the network using tcp, prefered method ?

In the boost examples in the documentation, tcp:iostream is used to very simply send streams over the network. In other examples write() is used to write data to the socket instead with a bit more code involved. What is the difference between those 2 methods? Pros and cons? Is there something else that should be used instead ? ...

CXX Test Framework for C++

How effective is the CXX test framework, given that you are writing unit test cases around the code that you have written. Any bug in the code might as well get translated into a bug in the unit test code as well? Isn't it something like two negatives make a positive? Also, the time and effort spent on CXX is at least equal to if not m...

Best approach to define a constant (used in a constant expression) in the class?

I am trying to define a constant BUFFER_LENGTH for my class for a given usecase. //1. Using preprocessor declaration //#define BUFFER_LENGTH 12 //2.Global constant //const int BUFFER_LENGTH = 12; class MyRequest { public: //3. Define an in-class constant //static const int BUFFER_LENGTH = 12; //4. Declare an enum constan...