c++

Does an R compiler exist?

I'm wondering about the best way to deploy R. Matlab has the "matlab compiler" (MCR). There has been discussion about something similar in the past for R that would compile R into C or C++. Does anyone have any experience with the R to C Compiler (RCC) that was developed by John Garvin at Rice? I've looked into it, and it seems to be...

API General Questions and Choices

I've decided to start making graphical games. My language of choice is C++ and the only game I've made so far was a text based game based on Hunt the Wumpus which taught me fundamentals of game loops and robust error handling. I now think I'm going to move onto a version of Tetris. Obviously moving from text-based to graphical programmi...

String Replace in C++

I've spent the last hour and a half trying to figure out how to run a simple search and replace on a string object in C++. I have three string objects. string original, search_val, replace_val; I want to run a search command on original for the search_val and replace all occurrences with replace_val. NB: Answers in pure C++ only. Th...

a virus in my visual c++ 2008?

Hey, so after a few months with JavaScript I decided to head back to my sweet c++. I started a new project and for the fun of it tried to compile the default file the comes up. now, everything looks weird already. the 'create project' wizard doesn't look how I remembered it. heck, even the main function is written differently now: #inc...

Shifting A Circular Array

I have a homework assignment that requires having to shift a circular array -n places in memory. I have accomplished the task with the following C++ Syntax: while ( r < 0 ) // rotate negatively. { if ( i == top+1 ) { current->n = items[top+1].n; items[top+1].n = items[back-1].n; } midPtr->n = items[+...

Advantages of knowing for a client, how big the package sended by the server is

I'm really new at network-programming, so I hope this isn't a complete Newbie-question. I read a tutorial at the Qt-Homepage how to build a little server, and I found this: QByteArray block; QDataStream out(&block, QIODevice::WriteOnly); out << (quint16)0; out << "..."; // just some text out.device()->seek(0); out << (quint16)(block.s...

RTSP library in Python or C/C++ ?

I am trying to find any RTSP streaming library for Python or C/C++. If not is there any other solutions for real time streaming? How much easy or difficult it is to implement RTSP in Python or C/C++ and where to get started? ...

Why is 'using namespace std;' considered a bad practice in C++?

Okay, sorry for the simplistic question, but this has been bugging me ever since I finished high school C++ last year. I've been told by others on numerous occasions that my teacher was wrong in saying that we should have "using namespace std;" in our programs, and that std::cout and std::cin are more proper. However, they would always b...

Is there an C++ equivalent to Python's "import bigname as b"?

I've always liked Python's import big_honkin_name as bhn so you can then just use bhn.thing rather than the considerably more verbose big_honkin_name.thing in your source. I've seen two type of namespace use in C++ code, either: using namespace big_honkin_name; // includes fn(). int a = fn (27); (which I'm assured is a bad thing) ...

How can I get polymorphic behavior in a C++ constructor?

I have a base class that I want to look like this: class B { // should look like: int I() { return someConst; } virtual int I() = 0; public B() { something(I()); } } The point being to force deriving classes to override I and force it to be called when each object is constructed. This gets used to do some bookkeeping and I...

How can I avoid using exceptions in C++?

What techniques can I use to avoid exceptions in C++, as mentioned in Google's style guide? ...

How to make elements of vector unique? (remove non adjacent duplicates)

I have a vector containing few non-adjacent duplicates. As a simple example, consider: 2 1 6 1 4 6 2 1 1 I am trying to make this vector unique by removing the non-adjacent duplicates and maintaining the order of elements. Result would be: 2 1 6 4 The solutions I tried are: Inserting into a std::set but the problem with this a...

UpdateLayeredWindow, SIZE_RESTORED and GetClientRect problem.

I have a layered window set up in my MFC application. I have set up my own derivation of CDialog to allow me to customise various parts of how the window is rendered. Everything works fine right up until I start worrying about minimise and maximise. If you click minimise or maximise then the window reacts exactly as you'd expect (ie...

Legit Uses of the offsetof Macro in C / C++

There is this macro offsetof in C/C++ which allows you to get the address offset of a member in a POD structure. For an example from the C FAQ: struct foo { int a; int b; }; struct foo; /* Set the b member of foo indirectly */ *(int *)((char *)foo + offsetof(b)) = 0xDEADBEEF; Now this just seems evil to me and I can't see many legi...

Discover if user has Admin rights

How can I determine if the current user (the user running my application) has admin rights (i.e. is a member of the Administrator group)? I need to register some COM components differently for users with limited access. I am using C++ (WTL and Win32). ...

Portable way to detect heap fragmentation in c++ at runtime?

I'm writing a qt-based c++ application and i need to be able to detect memory fragmentation in order to check if the current system can actually sustain the memory load: the program load a big image (15/21 megapixels are the norm) in memory and then perform some filtering on it (w/ sparse matrices). For instance, i'm having memory fragme...

What is good framework/library for C/C++ web programming?

Is C/C++ still used for web programming? What I mean by web programming is the typical CGI kind of applications which generates HTML on the fly. My main question is geared towards finding a suitable framework/library for C/C++ based web programming. What library/framework would you recommend for web programming with C/C++? I am not l...

Why is this snippet compilable in C?

Possible Duplicate: In C arrays why is this true? a[5] == 5[a] 3["zdvnngfgnfg"]; ...

Expected 1 argument(s) for "int system(const char *)"; had 2 instead.

void TATTDataset::AckErrHandler(const NDataString& ErrMsg) { system("echo ErrMsg: %s >> err", (const char *)ErrMsg); ...... code ....... } What does this error message mean? How do I resolve it? ErrMsg.toCString() doesn't help either. Any suggestion? EDIT: I edited the code as suggested - String s; Char *tmpStr = ErrMsg...

Sorting names with numbers correctly

For sorting item names, I want to support numbers correctly. i.e. this: 1 Hamlet 2 Ophelia ... 10 Laertes instead of 1 Hamlet 10 Laertes 2 Ophelia ... Does anyone know of a comparison functor that already supports that? (i.e. a predicate that can be passed to std::sort) I basically have two patterns to support: Leading number (as...