c++

Cross language development problem

I'm working on a project that involves a database (My SQL), website (PHP) and a custom high performance server application (C++). The C++ application (and its accompanying client application) make up the main bulk of the project, with the database storing long term data for it. The website is primarily for displaying various statistics, ...

C++ Linked list destroy function

Hi again, this is kinda a continue of my last question about linked list. I have worked a little more on it and I got stuck at some functions I need to implement. The one I have question on right now is the destroy() function. It is supposed to release memory of every list_ item . The approach is to remove every list_item recursivly fr...

Conditional compilation

How do I add conditional compilation to my makefile: say if I have a #ifdef SAVE_DATA in a cpp (.cc) file. ...

Getting user input from Win32 C++. WPARAM casted as int?

I'm working on a pre-existing codebase and I'm looking to have the user type any 1-2 digits followed by the enter key at any time during the code being run and pass that number to a function. Currently, user input is handled like so: LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent...

Static struct linker error

I'm trying to create a static struct in C++: static struct Brushes { static HBRUSH white ; static HBRUSH yellow ; } ; But its not working, I'm getting: Error 4 error LNK2001: unresolved external symbol "public: static struct HBRUSH__ * Brushes::white" Why? The idea is to be able to use Brushes::white, Brushes::yellow through...

C++: Core Dump Exception

I've successfully compiled this code, but when I get around to the last for loop in the main, I get a core dump handle_exception. How do I fix this? main.cpp #include <iostream> #include <string> #include <fstream> #include <vector> #include "DRSequence.h" using namespace std; vector <DRSequence> array; int indexOfSequenceWithFirstWo...

USB How do you create a bootable custom USB application?

Many LCD televisions nowadays have USB ports so you can plug in your camera and it becomes a camera gallery on the TV. I want to write a gallery program which, when plugged in to the TV, will start to cycle through the images on the USB device. How would I do this? Is it possible to write some sort of OS/application which can run on t...

Calling static pointer to a list from a shared library in c++

Hi, I have a static class member class bar {...} class foo { public: static QHash<qint64,bar>* barRepHash; } Now I call a function which accesses this member within a shared library, I get a memory error whereas when I access the function through the main program, it works fine. I've tested this under a number of circu...

Random bytes with fread

#post The names of my variables are not imporant! This code will be deleted when it works! #post Alright, so I'm using fread in stdio.h to read a text file. The problem is that I keep reading random bytes that don't exist in the text file from my knowledge. I'm assuming they are part of files scheme, but I just wanna make sure it's no...

Algorithm for finding path to point

I'm not sure if I worded this properly, but basically I have an object at point X,Y and I want an algorithm that can get this point to X',Y' but like show its route so I can animate it. I'm building a tile game and when the game starts I want the tiles to magically place themselves into a nice 2d array. So I will generate a random coordi...

MinGW/GCC Delay Loaded DLL equivalent?

Hello, I'm trying to port some old MSVC C++ code to MinGW/GCC. One problem is that the project relies heavily on the /DELAYLOAD option for functions that aren't always used, and where the proper dll is located at runtime. Is there such a similar option on MinGW/GCC? This code is targeting the windows platform. ...

What is the recommended way of passing keyboad events to QProcess transparently?

I have a GUI application, which creates a QProcess inside, catches its output and shows it on a form. I need to somehow catch key events from the form to pass them to QProcess (to make it fell as close as possible to real terminal window). So, I suppose, I should process keyReleaseEvent() and somehow transform either event.text() (which...

Boost's Interpreter.hpp example with class member functions

Boost comes with an example file in boost_1_41_0\libs\function_types\example called interpreter.hpp and interpreter_example.hpp I am trying to create a situation where I have a bunch of functions of different arguments, return types, etc all register and be recorded to a single location. Then have the ability to pull out a funct...

Converting STL String, and STL Vector into void*?

Ive got some C++ code, that we use to serialize arbitrary data and store it into a specialized image format as metadata. Anyways, it takes it as a void*. Can i just do a simple memcpy? Or is there a better way to do this? ...

String manipulation using Ardunio and C++

I am trying to manipulate a string in C++. I am working with an Arduino board so I am limited on what I can use. I am also still learning C++ (Sorry for any stupid questions) Here is what I need to do: I need to send miles per hour to a 7 segment display. So if I have a number such as 17.812345, I need to display 17.8 to the 7 s...

Determining output (printing) of float with %f in C/C++

I have gone through earlier discussions on floating point numbers in SO but that didn't clarified my problem,I knew this floating point issues may be common in every forum but my question in not concerned about Floating point arithmetic or Comparison.I am rather inquisitive about its representation and output with %f. The question is ...

Usage of 'short' in C++

Why is it that for any numeric input we prefer an int rather than short, even if the input is of very few integers. The size of short is 2 bytes on my x86 and 4 bytes for int, shouldn't it be better and faster to allocate than an int? Or I am wrong in saying that short is not used? ...

C++ can native type char hold End of File character?

The title is pretty self explanatory. char c = std::cin.peek(); // sets c equal to character in stream I just realized that perhaps native type char can't hold the EOF. thanks, nmr ...

simulate virtual constructor in c++

Hi, In my application I have to derive some classes from a base one, the problem is that I want to enforce the derived classed to have 3 particular constructor implementation. As c++ don't have virtual pure constructor, it seemed quite desperate (I had to check manually each class implementation to ensure that the particular ctors are i...

How to compute the output ?

How to compute the output for the recursive functions ? I know recursion invokes a stack, but am confusing while solving some aptitude question. Given the following code snippet: #include <stdio.h> void fun(int a){ if(a>0){ fun(--a); printf("%d ",a); fun(--a); printf("%d ",a); } return; } int main(void){ int num = 5; fun...