c++

run a function every x seconds in c++

I'm trying to build a feed reader in C++, so I need the program to check for new feeds intermittently. However, the user needs still to be able to interact with the program, so the suggestion that I seem to keep finding, to have the system wait, doesn't work for me. Can anyone suggest a better solution, say a timer that runs in the backg...

operator "new" returning a non-local heap pointer for only one class ?

Language : C++ Platform : Windows Server 2003 I have an exe calling a DLL. EDIT : (exe is not doing anything, it calls few global function which does everything related to DLL within DLL. It does not explicitly new any of DLL classes) I allocate (new) the memory for class A within the DLL, it returns me a non-local heap pointer. I...

libmcrypt and MS Visual C++

Has anyone tried using libmcrypt and visual c++? I was trying to use Crypto++ but it seems not fully compatible - and I need to decrypt data encrypted in PHP using linux libmcrypt. I found only cygwin version of libmcrypt but no .lib files or header. I'm using RIJNDAEL_128 - maybe there is easier way to decrypt it in Visual C++? Thank...

Formatting an integer in C++

I have an 8 digit integer which I would like to print formatted like this: XXX-XX-XXX I would like to use a function that takes an int and returns a string. What's a good way to do this? ...

How do I get started on a bigger project?

Hey guys, Most of the time I have been programming little apps either for myself or for the benifit of learning. Now that my programming skills are considered somewhat intermediate, I was wondering how I would tackle a large programming project. Lets suppose I wanted to make an application that has a lot of features and is intended for...

C++ socket concurrent server

Hi all; Im writing a concurrent server that's supposed to have a communication channel and a data channel. The client initially connect to the communication channel to authenticate, upon successful authentication, the client is then connected to the data channel to access data. My program is already doing that, and im using threads.My ...

Find location using only distance and bearing?

Triangulation works by checking your angle to three KNOWN targets. "I know the that's the Lighthouse of Alexandria, it's located here (X,Y) on a map, and it's to my right at 90 degrees." Repeat 2 more times for different targets and angles. Trilateration works by checking your distance from three KNOWN targets. "I know the that's the ...

what is better when creating new variable in a loop in c++

Hello, What is the best way in C++ to use std::map in loops ? dynamically allocated stack allocated Code: for(int i=0;i<3;i++) { std::map<int,int>* m = new std::map<int,int>; //or ... std::map<int,int> m; } ...

[C++] instantiating bitset using hex character.

Hey, I'm trying to figure out how to instantiate a 4 bit bitset based on a hex character. For instance, If I have a character with value 'F', I want to create a bitset of size 4 initialized to 1111 or if it is A, i want to initialize it to 1010. I could use a bunch of if statements like so: fn(char c) { bitset<4> temp; if(c == 'F')...

C++ return type overload hack

I was bored and came up with such hack (pseudocode): 1 struct proxy { 2 operator int(); // int function 3 operator double(); // double function 4 proxy(arguments); 5 arguments &arguments_; 6 }; 7 8 proxy function(arguments &args) { 9 return proxy(args); 10 } 11 int v = function(...); 12 double u = function(....

Can I un-check a group of RadioBottoms inside a group box?

radio bottoms inside a group Box will be treated as a group of bottoms. They are mutual exclusive. How can I clean up their check states?? I have several radio bottoms, one of them are checked. How can I "clean" (uncheck) all radio bottoms?? "setChecked" doesn't work within a group, I tried to do following things but failed. My code is...

Classes with the same name - is it restricted only within the same translation unit?

Let's just I had the following code: foo.h class Foo { // ... }; foo.cpp #include "foo.h" // Functions for class Foo defined here... Let's say that Foo are built into a static library foo.lib. Now let's say I have the following: foo2.h class Foo { // ... }; foo2.cpp #include "foo2.h" // Functions for class Foo define...

Passing optional parameter by reference in c++

I'm having a problem with optional function parameter in C++ What I'm trying to do is to write function with optional parameter which is passed by reference, so that I can use it in two ways (1) and (2), but on (2) I don't really care what is the value of mFoobar. I've tried such a code: void foo(double &bar, double &foobar = NULL) {...

Google Protocol Buffers - Fixed size buffer?

Hi All. Using Google Protocol Buffers, can I set a maximum size for all messages I encode? if I know that what I encode is never larger than X bytes, then Google Protobuffs would always produce a buffer of size Y, and if I give it a smaller amount of data, pad it to size Y? ...

List of header file locations for the Havok Physics Engine

Hello everyone! I am trying to integrate the Havok physics engine into my small game. It is a really nice SDK, but the header files are all over the place. Many headers are deeply nested in multiple directories. That gets confusing when you are trying to include headers for different important objects. I would like to know if there is a...

crash with CoUnintailize() api of COM

My main process(main.exe) initilaized COM library and created a thread which creates a new process(p1.exe) this new process is again initializing COM library and after making all references as zero unintialized COM here.. the unintailezed COM in the main process (i.e main.exe) also.... When i run p1.exe individually it is successful.. b...

Why can't QFile read from the "~" directory?

I've tried the following short example to find out about a bug in a bigger program I am working on. It looks like QFile doesn't support unix (or the shell's) notation for the home directory: #include <QFile> #include <QDebug> int main() { QFile f("~/.vimrc"); if (f.open(QIODevice::ReadOnly)) { qD...

Does the cppunit test frame have different version? if yes, then what is the latest version of it?

Does the cppunit test frame have different version? if yes, then what is the latest version of it? ...

Can a member struct be zero-init from the constructor initializer list without calling memset?

Let's say I have the following structure declaration (simple struct with no constructor). struct Foo { int x; int y; int z; char szData[DATA_SIZE]; }; Now let's say this struct is a member of a C++ class as follows: class CFoobar { Foo _foo; public: CFoobar(); }; If I declare CFoobar's constructor as follo...

Visual Studio 2010 C++ DLL project - No output DLL file!

I can compile the DLL project without any error. It says "Build succeeded". But I don't see any DLL file in the Debug or Release folder. There are only .exp, .lib and .pdb files ...