c++

memory allocation in C++

Is it possible to allocate an arbitrary memory block using the "new" operator? In C I can do it like "void * p = malloc(7);" - this will allocate 7 bytes if memory alignment is set to 1 byte. How to make the same in C++ with the new operator? ...

Get Last Error from LogonUser function and return it as a String?

Hey Folks, I am just wondering how i can get the error causing LoginUser function to fail in my C++ program and return it as a String? JNIEXPORT jstring JNICALL Java_com_entrust_adminservices_urs_examples_authn_LdapAuthenticator2_takeInfo(JNIEnv *env, jobject obj, jstring domain, jstring id, jstring idca, jstring password) { const...

Bind to any port available

I need an app that sends an UDP packet to some network server and receives the response. The server replies to the same port number where request came from, so I first need to bind() my socket to any UDP port number. Hardcoding the UDP port number is a bad idea, as it might be used by any other application running on the same PC. Is th...

using copy with multi-dimensional arrays

I'm just trying to get more into stl semantics, and converting old loops over to algorithms where appropriate. I'm having trouble figuring out the best way to transform this loop into a call to copy. Any ideas? vector< vector<float> > rvec; const float * r[Max] = ...; // ... for (int ri=0; ri<N; ri++) for (int ...

Reading delimited files in C++

What is the best way to read in a tab delimited file in C++ and store each line as a record? I have been looking for an open source library to help with this, but have been unsuccessful so it looks like I will have to write my own. ...

64 bit floating point porting issues

I'm porting my application from 32 bit to 64 bit. Currently, the code compiles under both architectures, but the results are different. For various reasons, I'm using floats instead of doubles. I assume that there is some implicit upconverting from float to double happening on one machine and not the other. Is there a way to control ...

Extending Python with C/C++

Can anyone please give me tips on the tools or sofware to use to extend Python with C/C++? Thanks. ...

Excel document parser/importer?

Can anyone recommend a decent Excel (Binary XLS) document importer written in C? I am looking to write a Ruby wrapper around one. I haven't been able to find any via Google. ...

How to mimic the "multiple instances of global variables within the application" behaviour of a static library but using a DLL?

We have an application written in C/C++ which is broken into a single EXE and multiple DLLs. Each of these DLLs makes use of the same static library (utilities.lib). Any global variable in the utility static library will actually have multiple instances at runtime within the application. There will be one copy of the global variable p...

Vector Graphics on Windows Mobile

I have to make an application that runs on both Windows (XP/Vista) and Windows Mobile. The graphics interface must be scalable (for different resolutions) and the controls must be custom (like the ones usually found on music apps). SVG was my instant choice but the lack of support on Windows Mobile pretty much kill my time budget. I've t...

C++ DLL Called From C# on Windows CE for ARM Always Returns 0

I am currently developing an application for Windows CE on the TI OMAP processor, which is an ARM processor. I am trying to simply call a function in a C++ DLL file from C# and I always get a value of 0 back, no matter which data type I use. Is this most likely some kind of calling convention mismatch? I am compiling the DLL and the m...

Incrementing iterators: ++it more efficient than it++?

Possible Duplicate: Is there a performance difference between i++ and ++i in C++? I am writing a program where an iterator is used to loop through a std::vector. Somebody told me that doing ++it in the for statement leads to more efficient code. In other words, they are saying that: for ( vector<string>::iterator it=my_vector.b...

How do you Make A Repeat-Until Loop in C++?

How do you Make A Repeat-Until Loop in C++? As opposed to a standard While or For loop. I need to check the condition at the end of each iteration, rather than at the beginning. ...

How to add properties to a file like the Windows Office documents?

How to add properties to a file like the Windows Office? In Windows, is possible to edit fields from a file like Title, Subject, Keywords etc. How to do the same with an arbitrary file from C/C++ without using Office? Do you have any hint about API, DLLs or general tricks? ...

Windows SearchPath function

I am using the following to search for a file defined as a macro DB_CONFIG_FILE_PATH_1. wchar_t filename[100]; SearchPath( L".\\", DB_CONFIG_FILE_PATH_1, NULL, 100, filename, NULL); If the file is in C:\ directory, it is found. But, if the file is in one of its sub-directories the function doesn't find it. Can some explain how to sea...

How do you Specify a Method to be a Destructor Rather than a Constructor in C++?

How do you specify a method to be a destructor rather than a constructor in C++? This confuses me very much. I can't tell the difference between the two. ...

OpenSource Instant Messaging APIs

Hi, I want to create my own IM and I'm searching an open-source IM APIs. What do you think is the best open-source IM APIs. And what good front end to use? Thanks. ...

Swig c++ w/ Java loses type on polymorphic callback functions

Question: Why is my C++ swigged object losing its type when passed to a Java callback function? Setup: I've taken the Swig Java example for doing callbacks and added an object to be passed to the callback run(Parent p). The callback works as expected but when I pass a Child object the Java seems to lose its type and think its of type Pa...

Internet Explorer 8 + Deflate

I have a very weird problem.. I really do hope someone has an answer because I wouldn't know where else to ask. I am writing a cgi application in C++ which is executed by Apache and outputs HTML code. I am compressing the HTML output myself - from within my C++ application - since my web host doesn't support mod_deflate for some reason....

How to run CPPUnit unit tests

I have written few c++ Unit tests using CPPUnit But I do not understand how to run those. Is there any tool like Nunit-gui? Currently I have written and packed tests in a DLL. When i google i found this http://cppunit.sourceforge.net/doc/lastest/cppunit_cookbook.html But i am not able to understand how does it get tests from a DLL...