c++

Error defining and initializing multidimensional array

I get error in compilation with the following definition. int matrix[ ][ ] = { { 1, 2, 3}, {4,5,6} }; char str[ ][ ] = { "abc", "fgh" }; Why is the compiler complaining missing subscript and too many initializers. ...

How to fold STL container

Hi! I need analog of Haskell's foldl function to fold any STL containers. Expected signature is like following: template Iterator, FoldingFunction, Result Result foldl( Iterator begin, Iterator end, FoldingFunction f, Result initValue); Standard STL has no such function. Does Boost have any? I know it's pretty simple to im...

Sort methods in cpp file by header

Hey folks, in my eyes it is good style to sort methods in header files in the same order as in the cpp file. But often this order gets crude during development. Does anyone knows a tool which can reorder the methods in the cpp file to the order given in the header file? Best regards, Gerrit ...

[VB.NET] Any way we can work with hex bytes and chars like in c++?

Well my question is simple and straightforward. Is there any way we can use hex values like in c++? I am going to write binary files, but for that i will have to define certain characters like this for example. \x00\x00\x11\x22\x33\x00\x00 I would first need to convert stuff like this to a byte array, and then write it to a binary te...

operator[]= overload?

Okay, I'm trying to make a quick little class to work as a sort of hash table. If I can get it to work then I should be able to do this: StringHash* hash = new StringHash; hash["test"] = "This is a test"; printf(hash["test"]); And it should print out "This is a test". It looks like I have 2 problems at this point. Firstly I d...

opencv every frame processing

Hi all! I want to write a crossplatform application using opencv for video capture. In all the examples, i've found frames from the camera are processed using the grab function and waiting for a while. And i want to process every frame in a sequence. I want to define my own callback function, which will be executed every time, when a new...

C++ scanf/printf of array

I've written following code: int main() { double A[2]; printf("Enter coordinates of the point (x,y):\n"); scanf("%d,%d", &A[0], &A[1]); printf("Coordinates of the point: %d, %d", A[0], A[1]); return 0; } It's acting like this: Enter coordinates of the point (x,y): 3,5 Coordinates of the point: 3, 267...

Using an object in unrelated class

I have the following situation: In project A, an object (say Obj1 of class A1) instantiates Obj2 of class A2. Then, from Obj1, by many code paths, an object Obj3 (of class A3) can be instantiated. The A3 class is in another project. The stack trace from Obj1's main method to instantiating an object of class A3 is 20 calls deep, and th...

malloc error C++

Possible Duplicate: malloc.c:3074 error? I am getting this strange error on execution of my C++ code: malloc.c:3096: sYSMALLOc: Assertion `(old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)((((__...

DirectShow CBasePin::ConnectedTo() returns a VFW_E_NOT_CONNECTED error after returning from Windows Lock

Hello everyone, We have an application that uses DShow filters to play video off of IP cameras. I'm currently trying to fix the following bug: Normally, the app will build a graph, connecting the video renderer filter and the source filter on request for live video feed. Now, if while the player is running the PC goes into windows lock...

Using exceptions within a boost::thread thread

Hello, I began to play around with boost::threads, but I'm kind of stuck with this problem: I don't understand why this program crashes as soon as the exception is thrown, because I try to catch it within the thread. I thought that it would be possible to work with exceptions as long as the handling happens in the same thread as the t...

TCP connection failure

I’m having trouble with a simple TCP socket with the connect() and read() function. This program works if I start the server first, and the client second. However, when I start the client first, it continues to try to connect to the server, then when I start the server, it connects but the subsequent read returns 0 bytes. This suggests t...

Eclipse CDT Source->Implement Method generates code not following defined code style

I am using Source->Implement Method sometimes, but I noticed that the generated code does not follow the defined code style from the preferences (the style is applied when I use Source->Format correctly) - Is there some setting I missed or is that a bug? Using Eclipse Version 3.5.2 and CDT 6.0.2 on Ubuntu Linux 10.04 LTS. Example: we d...

Dynamic Cast working on unrelated types

#include <iostream> using namespace std; class X{ public: virtual void f(){} }; class Y { public: virtual void g() {} }; int main() { X * x = new X(); Y* y = dynamic_cast<Y*>(x); //A // Y* y = static_cast<Y*>(x); //B cout << y << endl; } A compiles whereas B doesn't. I underst...

Language converter in C++ (from japanese to english)

Hi All, Once again i need ur help, i have a file in japanese language and i want to convert that file into english using C++, since i dont think that i can use any API's of google in c++, so any general idea can prove helpful for me, Please suggest something. Thanks a lot Owais Masood ...

jsoncpp on linux: multiple "warning: statement has no effect" in test cases

I'm building jsoncpp on andlinux (based on Ubuntu) and getting warnings in all the test cases which seem to indicate that the tests aren't called. Is anyone else here using jsoncpp on Linux - if so did you get the test cases to build properly? Looking at the jsoncpp forums there isn't much activity at the moment: would I be better off...

std::list fixed size

How can I create std::list with a fixed element count? ...

how to remove some data from pe (exe) file in C

hi, in first exe i have defined array of char with some special bytes as label, i mapping it to memory from another exe, finding needed label and putting in it new data, but this data could be shorter then defined array, so i want to cut this array to needed size! how can i do it? ...

Open WPF application in Windows in c++ application

I have a situation where I need to start a WPF application and have it run using a child window created by my C++ application. So the sequence of events would be - Start C++ application C++ application creates a window that it wants WPF app to run in. Launch WPF using CreateProcess function. Included in create process would be the ha...

OpenGL headers for OS X & Linux

I'd like to have both the includes for OS X as well as linux in my opengl program (C++) how can I set my program to use one if the other is not available? Here's what i'm currently doing: if(!FileExists(OpenGL/gl.h)) #include <GL/glut.h> //linux lib else { #include <OpenGL/gl.h> //OS x libs #include <OpenGL/glu.h> #incl...