c++

Passing variable arguments to another function that accepts a variable argument list

So I have 2 functions that both have similar arguments void example(int a, int b, ...); void exampleB(int b, ...); Now example calls exampleB, but how can I pass along the variables in the variable argument list without modifying exampleB (as this is already used elsewhere too). ...

Reading File Remotely in C++

Hi, Is there way that I can read the file from remote server using fopen or any other api. Thanks Avinash ...

Unit Testing in Qt with Highly Dependent Functions

I'm new to unit testing. I want to code unit tests in Qt, but my functions(login, request etc...) heavily depend on other resources such as a server. How can I supply a block box in this situation? Do you know any open source project which I can examine unit test classes for similar situations? ...

First Boost program

I have tried to write my first Boost program from information on the Boost libraries site. Here is the code: #include <boost/lambda/lambda.hpp> #include <iostream> #include <iterator> #include <algorithm> int main() { using namespace boost::lambda; typedef std::istream_iterator<int> in; std::for_each( in(std::cin)...

Syslog custom priorities

Is there a way one can use custom priorities in syslog daemon or rsyslog daemon? i.e. i am unable to locate a configuration change which achives it.. the other thing i can do is perhaps play with it's source. Cheers! ...

How to initialize a static member in C++ ?

Is it possible to initialize a static const value outside of Constructor ? at member declerations ? class A{ private: static const int a = 4; ... ... }; ...

string analysis

IF a string may include several un-necessary elements, e.g., such as @, #, $,%. How to find them and delete them? I know this requires a loop iteration, but I do not know how to represent sth such as @, #, $,%. If you can give me a code example, then I will be really appreciated. ...

Odd Parameter I dont understand in gridlabd threadpool.c

I'm working on the open project gridlabd hosted at sourceforge. I was trying to call the create_thread function: static __inline int create_thread(void * (*proc)(void *), void *arg) I just don't understand for the life of me what in the world void * (*proc)(void *) means..... As a side note, did stack overflow add an option for Jon Ske...

Have I found a bug in Clang?

I tried to compile the code below with Clang class Prasoon{ static const int dummy = 0; }; int const Prasoon::dummy = 0; int main(){} The above code did not give any error when compiled with Clang. prasoon@prasoon-desktop ~ $ clang++ --version clang version 2.8 (trunk 107611) Target: i386-pc-linux-gnu Thread model: posix prasoo...

Open souce virtual machine

I'm looking for a fast and much lightweight as possible open source virtual machine for implementing my custom programming language. The virtual machine should support some minimal set of bytecode (like LLVM IR), but can easily embedable from a C++ application (which filters out LLVM from the list). It should be wrriten in C/C++. I'm l...

A Clean Syntax for Changing Static Member Initialisation Behaviour

I recently read that Java now sports initialisation blocks like the following: class C { public C() { /* Instance Construction */ } static { /* Static Initialisation */ } { /* Instance Initialisation */ } } I was particularly interested in the static block. It got me thinking about the static initialisation order problem...

How can I find the IP address of a mapped network drive in C++?

I have a list of possible paths to use for a default input data directory (X:\Data; Y:\Data; Z:\Data). All of the possible paths are mapped network drives. I can check this using GetDriveType(pathStr) == DRIVE_REMOTE. To determine the best one, I have narrowed down the list by selecting only paths that exist. Sometimes there will be more...

Is there a c++ way to write file with any type of data

Like this function in C: size_t fwrite ( const void * ptr, size_t size, size_t count, FILE * stream ); I've looked in c++ file stream and found this one: ostream& write ( const char* s , streamsize n ); this one only accepts char* instead of void* but does it really matter if i use a c-style fwrite function in c++> ...

Catch derived exception when returning reference of base class type?

Hi, I'm writing a windows application in C++ and encountered the following problem when working with exceptions. I have a base exception class from which all other exceptions derive from. In the base class I have a method for the error message of any exception. That method then returns the exception (through '*this'). Now, the problem...

What's wrong with the c++ code below?

HRESULT SaveGraphFile(IGraphBuilder *pGraph, WCHAR *wszPath) { const WCHAR wszStreamName[] = L"ActiveMovieGraph"; HRESULT hr; IStorage *pStorage = NULL; // First, create a document file that will hold the GRF file hr = StgCreateDocfile( wszPath, STGM_CREATE │ STGM_TRANSACTED │ STGM_READWRITE │ ...

Thread-ring benchmark

Today I was doing the thread ring exercise from the Programming Erlang book and googled for other solutions to compare. I found that the language shootout has exactly this the same problem as a benchmark. I had the impression that this is an area where Erlang should be fastest, but turns out that C and C++ are again on top. My suspicion ...

Alternative to _input in VS2010?

Hey all, I recently ported a project from Visual Studio .NET 2003 to Visual Studio 2010. The problem here is that my code uses the built-in VC++7.1 _input. _input is used in a function which simulates the functionality of GNU glibc's vsscanf(). I realize that VS2010 provides _input_l as a replacement, however this function crashes con...

Multiple preprocessor directives on one line in C++

A hypothetical question: Is it possible to have a C++ program, which includes preprocessor directives, entirely on one line. Such a line would look like this: #define foo #ifdef foo #define bar #endif What are the semantics of such a line? Further, are there any combinations of directives which are impossible to construct on one li...

Accessing vertices in the triangle++ (delaunay/voronoi triangulation) Wrapper class

Hi, I'm using the triangle++ wrapper class from http://www.compgeom.com/~piyush/scripts/triangle/ to triangulate a point cloud for visulaizing with OpenGL. I was able to put in my points and caluculate the triangulation. After that i also was able to access the vertices over a vertex iterator, how it is shown in the main.cpp example inc...

How to change indentation etc of a piece of code?

Possible Duplicates: Code polisher / reformater for C, C++ or Fortran Best C++ Code Formatter/Beautifier I am working as part of a team on a C++ project. Part of the code is a highly modified version of a large-ish external library, which doesn't conform to our coding conventions. The library uses this style: void main () ...