c++

Different sizeof results

Why does n not equal 8 in the following function? void foo(char cvalue[8]) { int n = sizeof cvalue; } But n does equal 8 in this version of the function: void bar() { char cvalue[8]; int n = sizeof cvalue; } ...

Can cout alter variables somehow?

So I have a function that looks something like this: float function(){ float x = SomeValue; return x / SomeOtherValue; } At some point, this function overflows and returns a really large negative value. To try and track down exactly where this was happening, I added a cout statement so that the function looked like this: flo...

Calling python from a c++ program for distribution

I would like to call python script files from my c++ program. I am not sure that the people I will distribute to will have python installed. Basically I'm looking for a .lib file that I can use that has an Apache like distribution license. ...

How can I embed Perl inside a C++ application?

I would like to call Perl script files from my c++ program. I am not sure that the people I will distribute to will have Perl installed. Basically I'm looking for a .lib file that I can use that has an Apache like distribution license. ...

How can I use a key blob generated from Win32 CryptoAPI in my .NET application?

I have an existing application that is written in C++ for Windows. This application uses the Win32 CryptoAPI to generate a TripleDES session key for encrypting/decrypting data. We're using the exponent of one trick to export the session key out as a blob, which allows the blob to be stored somewhere in a decrypted format. The question i...

What is the cleanest way to direct wxWidgets to always use wxFileConfig ?

I am writing my first serious wxWidgets program. I'd like to use the wxConfig facility to make the program's user options persistent. However I don't want wxConfigBase to automatically use the Windows registry. Even though I'm initially targeting Windows, I'd prefer to use a configuration (eg .ini) file. Does anyone know a clean and simp...

How does one decrypt a PDF with an owner password, but no user password?

Although the PDF specification is available from Adobe, it's not exactly the simplest document to read through. PDF allows documents to be encrypted so that either a user password and/or an owner password is required to do various things with the document (display, print, etc). A common use is to lock a PDF so that end users can read i...

64 bit tools like BoundsChecker & Purify

For many years I have used two great tools BoundsChecker & Purify, but the developers of these applications have let me down, they no longer put effort into maintaining them or developing them. We have corporate accounts with both companies, and they both tell me that they have no intention of producing versions to support 64 bit applica...

Database abstraction layers for (Visual) C++

What options exist for accessing different databases from C++? Put differently, what alternatives are there to ADO? What are the pros and cons? ...

create and stream large XML document in C++

I have some code that creates a fairly large xml DOM and writes it off to a file (up to 50-100MB) . It basically creates the DOM and then calls a toString on it and writes it out with ofstream. Is there a way to get streaming output of the generated dom so that it doesn't create the whole structure in memory all at once and then copy it,...

Favorite C++ interview question

What is your favorite C++ interview question? It may be any question, for example: algorithms, multithreding, gamedev area, low-level system programming, strings... ...

Is there a difference between foo(void) and foo() in C++ or C

Consider these two function definitions void foo(){} void foo(void){} Is there any difference between these two? If not, why is the void argument there? Aesthetic reasons? ...

High availability and scalable platform for Java/C++ on Solaris

I have an application that's a mix of Java and C++ on Solaris. The Java aspects of the code run the web UI and establish state on the devices that we're talking to, and the C++ code does the real-time crunching of data coming back from the devices. Shared memory is used to pass device state and context information from the Java code thro...

How to host licensed .Net controls in unmanaged C++ app?

I need to host and run managed controls inside of a purely unmanaged C++ app. How to do this? To run unlicensed controls is typically simple: if (SUCCEEDED(ClrCreateManagedInstance(type, iid, &obj))) { // do something with obj } When using a licensed control however, we need to somehow embed a .licx file into the project (ref app...

Finding unused files in a project

We are migrating our works repository so I want to do a cull of all the unreferenced files that exist in the source tree before moving it into the nice fresh (empty) repository. So far I have gone through by hand and found all the unreferenced files that I know about but I want to find out if I have caught them all. One way would be to ...

Is there a need to destroy char * = "string" or char * = new char[6]

I assume when I do char* = "string" its the same thing as char* = new char[6]. I believe these strings are created on the heap instead of the stack. So do I need to destroy them or free their memory when I'm done using them or do they get destroyed by themselves. ...

Lightbox style dialogs in MFC App

Has anyone implemented Lightbox style background dimming on a modal dialog box in a MFC/non .net app. I think the procedure would have to be something like: steps: Get dialog parent HWND or CWnd* Get the rect of the parent window and draw an overlay with a translucency over that window allow the dialog to do it's modal draw rou...

Do you know of a good program for editing/translating resource (.rc) files?

I'm building a C++/MFC program in a multilingual environment. I have one main (national) language and three international languages. Every time I add a feature to the program I have to keep the international languages up-to-date with the national one. The resource editor in Visual Studio is not very helpful because I frequently end up le...

How to get file extension from string in C++

Given a string "filename.conf", how to I verify the extension part? I need a cross platform solution. ...

What is the point of clog?

I've been wondering, what is the point of clog? As near as I can tell, clog is the same as cerr but with buffering so it is more efficient. Usually stderr is the same as stdout, so clog is the same as cout. This seems pretty lame to me, so I figure I must be misunderstanding it. If I have log messages going out to the same place I have e...