c++

Initialize array variable in structure

I ended up doing like this, struct init { CHAR Name[65]; }; void main() { init i; char* _Name = "Name"; int _int = 0; while (_Name[_int] != NULL) { i.Name[_int] = _Name[_int]; _int++; } } ...

Execute another program in C++

Hey folks, I want to remotely execute another application from my C++ program. So far I played along with the CreateProcess(...) function and it works just fine. The problem however is that I need the full path of the other program but I do not know the directory of it. So what I want is that I just have to enter the name of the other ...

Find Boost BGL vertex by a key

Hi, I am looking for a way to access vertex properties by using a key instead of vertex reference itself. For example, if I have class Data { public: std::string name; unsigned int value; }; typedef boost::adjacency_list< boost::vecS, boost::vecS, boost::directedS, Data > Graph; typedef boost::graph_traits<Graph>::vertex_d...

Building an FPS in OpenGL: My gun is being clipped agains the frustum

Hi, I'm building a first person shooter using OpenGL, and I'm trying to get a gun model to float in front of the camera. I've ripped a model from Fallout 3 using a resource decompiler (converted to .obj and loaded in). However, this is what it looks like on the screen: Half the gun's triangles are clipped to what appears to be the ...

glibc detected error

Hey, Can anybody please help me make sense of this error message? *** glibc detected *** ./kprank_new3_norm: munmap_chunk(): invalid pointer: 0x00000000096912d0 *** ======= Backtrace: ========= /lib64/libc.so.6(cfree+0x1b6)[0x3df6e75a36] ./kprank_new3_norm[0x409277] ./kprank_new3_norm[0x4092a9] ./kprank_new3_norm[0x4092ea] ./kprank_new3...

IMAP library - Proxy support

I am writing an application using IMAP support. But the IMAP library that I am using does not support Proxy. Can anyone point me to such an open source library which supports proxy? And what IMAP library Thunderbird is using? I am using "C/C++". ...

trying to make a simple grid-class, non-lvalue in assignment

I'm implementing a simple C++ grid class. One Function it should support is accessed through round brackets, so that I can access the elements by writing mygrid(0,0). I overloaded the () operator and i am getting the error message: "non-lvalue in assignment". what I want to be able to do: //main cGrid<cA*> grid(5, 5); grid(0,0) = new...

Qt - QScrollArea widget clipping contents

I'm trying to add scrolling to a drag and drop example source that I modified. The example simply draws several draggable QLabel widgets. I was modifying it in a way that a larger number of various different length widgets would be created. I made a class that would be called by main and would contain the scrolling widget, that in turn ...

How do I make an MFC control register for its own messages/events?

I am working on a class derived from CRichEditCtrl. I want an instance of my class to know: Update: solved it now. when it has been Created (i.e the HWND is non-null) when it gains/loses focus when the text changes when the selection changes when a right-click has happened (I'm guessing through EN_MSGFILTER) For 1, I found that over...

Dynamic programming algorithm N, K problem

An algorithm which will take two positive numbers N and K and calculate the biggest possible number we can get by transforming N into another number via removing K digits from N. For ex, let say we have N=12345 and K=3 so the biggest possible number we can get by removing 3 digits from N is 45 (other transformations would be 12, 15, 35...

Error creating an OpenGL control in a wpf window on windows 7

I have created an OpenGL control in C++ and wish to use this in a WPF application. I have successfully accomplished this and it works fine on Vista and XP machines but when I open my project on a windows 7 machine the WPF design window will not display. When I try to run the program I get the exception: "Cannot create instance of 'Win...

C++ Urban Myths

I'm starting to write an article on what I'm calling "C++ Urban Myths" - that is, ideas and conceptions about C++ that are common but have no actual roots in reality. Some that I've come up with so far are: TR1 is part of standard C++ TR1 (technical Report #1) proposed a whole bunch of changes to C++. Unfortunately, it was never acce...

iterator_range in header file

I want to specify in a header file that the input to a function will be an iterator_range, and the iterator can be dereferenced to obtain an int. What is the best way to do this? I do not want to say iterator_range<std::vector<int>::iterator> as this binds the implementation to use std::vector<int>. Would appreciate any ideas to specify...

how to do this in c++gui

I want to write a program for UNIX in C++ with GUI (planning it to be Qt). I haven't learned the Qt library yet btw. I want the program to be like a world map that will be divided into many cells like a grid(the grid shouldn't be visible) and when i start to ping some IP it will show me that IP location on the world map (select it like a...

C++ Pass by value/reference

I have the following code snippet: vector<DEMData>* dems = new vector<DEMData>(); ConsumeXMLFile(dems); if(!udp_open(2500)) { } I want the ConsumeXMLFile method to populate the vector with DEMData objects built from reading an XML file. When ConsumeXMLFile returns, the dems vector is empty. I think I'm running into a pass ...

C++ / templates / GCC 4.0 bug?

Hi guys, Provided the code below: template<class _ResClass, class _ResLoader=DefaultLoader> class Resource : public BaseResource { private: _ResClass data_; public: explicit Resource(const std::string& path) : data_( _ResLoader::load< _ResClass >( path )) { }; }; Why would it fail but this one will work?: template<c...

c++ fatal error c1083 project was fine before, what now?

I have a (com) c++ project, which uses a (.net) c++ dll. The project was compiling and running ok. Now, all I did was make changes to the dll, and I'm getting a fatal error c1083- cannot open include file stdafx.h - when recompiling my (com) project. What can this mean? ...

boost local_date_time math wrong?

I'm using Boost's datetime library in my project. I was very happy when I discovered that it has time duration types for hours, days, months, years, etc, and they change their value based on what you're adding them to (i.e. adding 1 month advances the month part of the date, it doesn't just add 30 days or somesuch). I thought this prop...

Exchanging objects between C# and C++

Imagine a project with a C# component and a C++ component. The C++ component is the old-school non .Net stuff (VC++ 6.0). What is an easy way to transfer objects between the two components? I'm tempted to use System.Xml.XmlSerializer, but I'm not sure how to start getting at the .Net libraries with this old VC++ app. Maybe there's an...

Mapping a thread number to a (non sequential) position in an array

I would like to map a thread_id. This in C/CUDA but it is more an algebraic problem that I am trying to solve. So the mapping I am trying to achieve is along the lines: Threads 0-15: read value array[0] Threads 16-31: read value [3] Threads 32-47: read value [0] Threads 48-63: read value [3] Threads 64-79: read value array[6] Thread...