c++

unable to construct a complex structure in c++

hi, I have two base structures like following : struct stuSectionProperties { int Field1; // Row | BoxNo | SplitterNo int Field2; // Col | Adapter | - double Latitude; bool IsEast; int Band; int CableNo; SDP::Global::enuSections::Type Section; stuSectionProperties() { this->Field1 = -...

Automatic Clustering With Hash/Map of Vectors in C++

I have the following values for example: 0 0 0 1 3 2 These values refers to cluster Ids, where the member of the cluster is the index of the vector. Hence we want to get this sort of output: Cluster 0 -> 0,1,2 Cluster 1 -> 3 Cluster 2 -> 5 Cluster 3 -> 4 I tried the following construct but it doesn't seem to work: What's the way t...

building boost python examples using Visual Studio 2008

I'm using Boost Python library to create python extensions to my C++ code. I'd like to be able to invoke from python the 'greet' function from the C++ code shown below: #include <boost/python/module.hpp> #include <boost/python/def.hpp> char const* greet() { return "hello, world"; } BOOST_PYTHON_MODULE(hello_ext) { using namespa...

C/C++ editor that can create projects from lists of files.

I recently asked a question about importing from a list of source/header files in Eclipse I haven't found a good solution to this, so I thought I'd check out other IDEs. I want an IDE that does not need to "own" everything from a top directory and down. When creating a new project I want to have a text file that lists source/header fil...

How to draw & export a transparent image with Nokia Qt C++ ?

I have a piece of code intended for drawing & exporting a transparent image with Nokia Qt. However, it does not work. I always see black background with lots of noise. I must fill the background with White color but I want transparency, not white color. Please kindly advise. #include <QtGui/QApplication> #include <QtGui> int main(int a...

Getting a simple Neural Network to work from scratch in C++

I have been trying to get a simple double XOR neural network to work and I am having problems getting backpropagation to train a really simple feed forward neural network. I have been mostly been trying to follow this guide in getting a neural network but have at best made programs that learn at extremely slow rate. As I understand ne...

Linkage to/from non C++ code

Hi guys, I did used snippet found from Internet for this kind of linking, and it works. Now I would like to gain more understanding on this topic, i.e. what should I pay attention to if my C++ code is going to be export/linked by non-C++ code. Could somebody points me to any resources useful for this? Thanks. ...

String reference run-time error

I have the following program which is giving run time error: The instruction at "x" referenced memory at "y" The memory could not be written. int main() { char *str1 = "Rain"; char *&str2 = str1; cout << str1 << str2 << endl; *str1 = 'M'; cout << str1 << str2 << endl; *str2 = 'P';//Here the error happens ...

performance of fread/fwrite while doing operation with binary file

Hi All, I am writing some binary data into a binary file through fwrite and once i am through with writing i am reading back the same data thorugh fread.While doing this i found that fwrite is taking less time to write whole data where as fread is taking more time to read all data. So, i just want to know is it fwrite always takes less t...

How to check if window proc is not corrupted in call to CallwindowProc?

I need to call API CallWindowProc((WNDPROC)lpfnOldProc, hWnd, Message, wParam, lParam); Now how can I make sure that lpfnOldProc still valid ? Basically,lpfnOldProc is procedure in another dll and if that dll is unloaded then lpfnOldProc will still be pointing to something but not valid memory? Are there some memory API's through w...

What's the best(easiest) way to transfer data on C/C++

Hey people! Currently I'm working on a C/C++ cross-platform client/server software. I'm very experienced developer when it comes to low level socket development. The problem with Berkley sockets/Winsock, is that you always have to make some kind of parser to get things right on the receiver side. I mean, you have to interpret data, and ...

Preincrement faster than postincrement in C++ - true? If yes, why is it?

Possible Duplicate: Is there a performance difference between i++ and ++i in C++? I heard about that preincrements (++i) are a bit faster than postincrements (i++) in C++. Is that true? And what is the reason for this? ...

generating 'random' number using modulo from a stream of odd numbers

Hi, i want to generate a pseudo-random bool stream based on a modulo operation on another stream of integers (say X), so the operation would be return ( X % 2); The only problem is that X is a stream of integers that always ends in 1, so for instance would be somehing like 1211, 1221, 1231, 1241 .... is there a way for me to disregar...

Matrix multiplication in GSL-GNU

Kindly tell me the function of matrix multiplication in GSL library. I have searched a lot but I am not be able to fine it. If any one know about that function kindly answer. Thanks in advance. ...

glPolygonOffset() bugs with lines

I have the following code: glEnable(GL_POLYGON_OFFSET_LINE); glPolygonOffset(1,1); // or 40,40 etc... doesnt help at all But the lines are still z-fighting, is this common bug or something...? My lines are 1.0f thick and i draw the lines last in the scene. Also i have disable GL_ALPHA_TEST and GL_LINE_SMOOTH and enabled GL_BLEND and ...

How should i randomly call class member methods ?

Hi there. I am writing a small "quiz program". It looks similar to this: #include <cstdlib> #include <iostream> #include <time.h> using namespace std; using std::cout; class cQuestion { private: static short goodAnswers[20][2]; public: static void checkAnswer(int questNumber) { /* checking input, checking if ...

my c++ client/server file exchange implementation is very slow...why?

Hi have implemented simple file exchange over a client/server connection in c++. Works fine except for the one problem that its so damn slow. This is my code: For sending the file: int send_file(int fd) { char rec[10]; struct stat stat_buf; fstat (fd, &stat_buf); int size=stat_buf.st_size; while(size > 0) { char buffer[1024]; ...

how to convert a binary array with hex values into decimal and then to a string

I have a binary array with hex values and i would like to convert it into decimal. once that is done i would like to display it in a string. BTW i am working on an intel process via unbuntu and this will probably be used on a sun many hp unix box. so the question i have is that when i do a straight up assignment to unsigned long it wor...

Seeking code stub generator (from header files)

Imagine I have the header files to a subsystem, but no access to the source code. Now I want to generate stubs to match all functions declared in the header files (for testing purposes). I wrote some simple code to do this, but it's not perfect. Does anyone know of any freely available software which will do this? ...

Seeking a true "tool-chain"

I just posted this as part of a reply to a question about the "best" bug-tracking software... Well, a tool on its own is just a tool. And while all speak of a toolchain, most just mean a loose collection of tools. Why not look for a problem tracker that "plays well with other children"? That is to say, interfaces well with your IDE, y...