c++

C++ String manipulation - if stament

I have the following code that works correctly. However after I add an else statement anything always evaluates to else wgetstr(inputWin, ch); //get line and store in ch variable str = ch; //make input from char* to string if(str=="m" || str=="M"){ showFeedback("Data Memory Updated"); } if(str=="p" || ...

Boost cheat sheet

I just had a hell of a project doing simple operations on C++, then when I was almost completely done with the project I found out that all this stupid tasks required just a portion of boost. This was quite frustrating and let me wondering how many of these annoying problems could be solved with a single function of the boost libraries. ...

Soundflower input applications

Hello, I've downloaded the source of Soundflower and I am trying to retrieve a list of all applications currently sending data to Soundflower. I'd like to manipulate each application's sound separately just like JACK and Audio Hijack does. Any ideas? ...

Are double* and double** blittable types? C#

Hello, I have a question regarding marshalling of C++ arrays to C#. Does the double* automatically convert to double[]? I know double is a blittable type, so double from C++ is the same as double from C#. And what about double**, does it convert to double[,] ? I have the following unmanaged function: int get_values(double** param,in...

array reallocation C++

Suppose you have an array, items, with capacity 5 and suppose also you have a count varaible that counts each entry added to the array. How would you realloacte the array? Using C++ syntax? void BST::reallocate() { item *new_array = new item[size*2]; for ( int array_index = 0; array_index < size * 2; array_index++ ) { ...

C++ convert int and string to char*

This is a little hard I can't figure it out. I have an int and a string that I need to store it as a char*, the int must be in hex i.e. int a = 31; string str = "a number"; I need to put both separate by a tab into a char*. Output should be like this: 1F a number ...

How to obtain the PIDL of an IShellFolder

If I have an IShellFolder interface pointer, how might I obtain its PIDL? I can see how to enumerate its children, and I can see how to use it to compare any two children... but how might I get its own pidl? I ask because I'd like to know "Is this IShellFolder == Another IShellFolder". I can use IShellFolder::CompareIDs() - but I have...

Causing push_back in vector<int> to segmentaion fault on what seems to be simple operation

I'm working on a program for Project Euler to add all the digits of 2^1000. So far I've been able to track the program segmentation faults when it reaches around 5 digits and tries to push a one onto the vector at line 61 in the function carry(). #include <iostream> #include <vector> #include <string> using namespace std; class MegaN...

Open CV + Visual Studio 2008 weird Debugging problem

I've recently installed OpenCV2.0 under Visual Studio 2008 professional edition, built the libraries, dll-s and got everything working but when I run the first example program: #include “highgui.h” int main( int argc, char** argv ) { IplImage* img = cvLoadImage( argv[1] ); cvNamedWindow( “Example1”, CV_WINDOW_AUTOSIZE ); cvShowImage( “E...

[C++] Enum declaration inside a scope that is a parameter of a macro.

Hi, I am trying to create a macro that takes a scope as a parameter. I know, it is probably not a good thing etc etc. I was trying this and got the problem that preprocessor looks for commas and parentheses... the problem is with enum. How would I declare a enum inside a scope that is a parameter of a macro? when the compiler see ...

wxWidgets and "Implement_App" causes _main duplicate symbol error

I'm compiling a trivial wxWidgets app on MacOS X 10.6 with XCode 3.2 The linker is return an error about the symbol _main being defined twice: once in main.mm once in the test_app.cpp file. After I commented out the macro: Implement_App(TestApp) The error went away, compiled & linked and I was able to run the application. ...

Google Mock for iPhone development?

I have an interesting situation where I am refactoring a bunch of ObjC iPhone code to create a C++ API. I'm a novice to C++ and looking into C++ mocking frameworks to augment the work I'd done using OCUnit and poor man's mocks. I ran across googlemock and wanted to know if anyone has ever used it for iPhone development? Also, how can I s...

parsing response end with extended SMTP (ESMTP)

To use an example response from google when sent "EHLO": 250-mx.google.com at your service, [66.501.941.15] 250-SIZE 35651584 250-8BITMIME 250-AUTH LOGIN PLAIN 250-ENHANCEDSTATUSCODES 250 PIPELINING Hex: 32 35 30 2D 6D 78 2E 67 6F 6F 67 6C 65 2E 63 6F 6D 20 61 74 20 79 6F 75 72 20 73 65 72 76 69 63 65 2C 20 5B 39 32 2E 34 32 31 2E 35...

OpenGL 3D Selection Question

I am trying to create a 3D robot that should perform certain actions when certain body parts are clicked. I have successfully (sort of) implemented picking in that if you click on any x-plane part, it registers a hit, but not anywhere else. That is, it is not registering depth, and if you clicked on it's square head, you could only regis...

Using Retrieve Method to Find for Remove, BST C++

To make deletion of a leaf easier, im wondering how i can use my retreive method(which finds a node) to first retreive it before i delete. So that way i dont have to recode the same looping scheme that is in retreive: bool BST::retrieve(const char *key, data& aData) const { for ( int i = 0; i < maxSize / 2; i++ ) {//iterate ...

C++ HTTP / HTML Socket Question

I'm building an application which I'd like to have it connect to a website and parse some data off it. I'm wondering if anyone could provide me some raw example code. I don't necessarily need help parsing, I'm just wondering in C++ how would I go about downloading the data from the page into my app so that I can start parsing the data I...

Modeling "optional" inheritance

I'm having trouble deciding on a way to model this type of relationship... All bosses can do certain things and have certain things (velocities, health, etc.) so these are part of the "main" abstract boss class. class Boss // An abstract base class { //Stuff that all Bosses can do/have and pure virtual functions }; Now I want to ...

WriteFile function "freezes"

Hi! I'm trying rewrite xCmd which can start a process on a remote machine. Basically it installs itself as a service on the target computer and then starts the requested process. Everything is working fine, but i noticed an error. xCmd is communicating through pipes, and it uses WriteFile(). My problem is, that if i run my API (or the o...

Is it possible to stack Yacc grammar rule code?

Lets say I need to run some initialization code everytime I match a rule how can I reduce the redundancy? rule : TOKEN1 { init(); token1Code(); } | TOKEN2 { init(); token2Code(); } ; Also is it possible to do something like rule : TOKEN1 | TOKEN2 { codeForToken1OrToken2(); } ; ...

Incomplete Type memory leaks?

Microsoft Visual Studio 2008 is giving me the following warning: warning C4150: deletion of pointer to incomplete type 'GLCM::Component'; no destructor called This is probably because I have defined Handles to forward declared types in several places, so now the Handle class is claiming it won't call the destructor on the given object....