Hi,
Newbie here.
Given the following string, "Hi ~+ and ^*. Is ^* still flying around ~+?"
I want to replace all occurrences of "~+" and "^*" with "Bobby" and "Danny", so the string becomes:
"Hi Bobby and Danny. Is Danny still flying around Bobby?"
I would prefer not to have to call Boost replace function twice to replace the occurr...
I have a program that I built for RHEL5 32 bit and ubuntu10 64 bit (c++ qt4.6). When I run the program on ubuntu, all the variables are initialized without me needing to code this initialization. But When I run the program on RHEL, some of the variables are not initialized, I have noticed that they are mostly integer type and the typic...
My question is based on curiosity and not whether there is another approach to the problem or not. It is a strange/interesting question, so please read it with an open mind.
Let's assume there is a game loop that is being called every frame. The game loop in turn calls several functions through a myriad of if statements. For example, if...
I recently reformated which led me to install MSVC 2010. Everything seemed okay, except this time around I had Windows x64. I went ahead and rebuilt all of the dependencies for my project as x32 as some of them have issues with x64, but I am having this error message popup before my application even starts as debug build (it crashes imme...
Preferably in C++, but code in all languages would be good to. Should be well categorized for different purposes, and have side by side comparisons.
To clarify what I'm looking for. Let's say I wanted to find a graphics library. I would search for that, and it would give me a list:
SDL
OpenGL
Ogre
Allegro
etc...
Each one would be r...
given an edge enum such as this:
none, top, left, bottom, right,
Given 2 rectangles, how could I find which edge of rectangle A that rectangle B is intersecting? I do not need to know which edge of B hit an edge of A, I just need to know which edge of A that B hit.
I found this algorithm but it does not return the specific edge:
bo...
This is definitely going to be one of my more arcane questions, but I hope someone has had to deal with this pain.
I am porting some software to IBM AIX 5.3, using IBM VisualAge C++ 7.0 compiler. The source code depends on boost.asio for networking, and when I was building the code, I got an error from the source:
include/boost/asio...
I want to display a textured quad that has its texture uninterfered. As I have it now, my program creates a texture of dimensions 32x32 and loads a texture into it. I created a vertex buffer with a FVF of D3DFVF_XYZRHW and D3DFVF_TEX1, and 4 vertices that make up a 32x32 quad. At first glance when it displays it looks fine, but the probl...
Hi,
I am writing a server program where it receives message from client and broadcast message to all previous clients. I need to create a shared memory between processes, but it seems that the shared memory is not working.
Here is my code:
int shmid2; key_t key2; void* shm2;
string name_list;
key2=ftok("tmp",'d');
//create
if ((...
I'm having trouble getting something to compile. I don't understand the error thrown out
by the compiler. Some code to illustrate the problem is below.
#include <map>
using namespace std;
class Thing
{
public:
Thing(int n):val(n) {}
bool operator < (const Thing& rhs) const
{
return val < rhs.val;
}
int ...
A default winAPI application does not have double-buffering. Instead, it does a very, very good job of ensuring that only what needs to be drawn is drawn, and that gives it a seamless appearance. However, when you resize the window, the entire thing needs to be redrawn, and this causes flickering between the controls, the background on t...
Possible Duplicate:
What is the difference between char s[] and char *s in C?
I was wondering what is the difference between
char *p1 = "some string";
and
char p2[] = "some string";
in terms of memory, can these not be treated in the same way?
e.g.
void foo(char *p);
...
foo(p1);
foo(p2);
...
I have sub classed a tab control to give it a background. I have used the clipping functions to clip the drawing area to the update region. This works, except for when I move the window of the screen and back again.
When it does this, it occasionally sets the clipping region to the whole screen. This is fine except that none of the cont...
I just started programming using C++. I face some problem during execution of ifstream in loop.
do
{
system("cls");
inFile.open ("Account_Details.txt");
while (!inFile.eof())
{
getline (inFile, line);
cout << line << endl;
}
inFile.close();
cin.ignore(100, '\n')...
Hello,
I'm writing an SDL application for Linux, that works from the console (no X server). One function I have is a file copy mechanism, that copies specific files from HDD to USB Flash device, and showing progress of this copy in the UI. To do this, I'm using simple while loop and copying file by 8kB chunks to get copy progress. The p...
After extensive reading of ISO/IEC 14882, Programming language – C++ I'm still unsure why const is needed for implicit conversion to a user-defined type with a single argument constructor like the following
#include <iostream>
class X {
public:
X( int value ) {
printf("constructor initialized with %i",value);
}
}
void impl...
I need to build up a path to a file. I have the following class method:
void Directory::scanDirectory(char *directory) {
DIR *dirp;
struct dirent *entry;
char path[1];
if(dirp = opendir(directory)) {
while(entry = readdir(dirp)) {
if (entry->d_name[0] != '.') {
strcpy(path, directory)...
I'm working on an audio creation framework. It'll be generating large audio files, say 3 minute long audio files that take about 1 minute to generate. So what I want is a system much like streaming audio from the internet, where I play the sound as I generate it.
Pygame's mixer allows me to edit the sound as it's playing. But I cannot fi...
What is the best way to bind an rvalue reference to either a given object or a temporary copy of it?
A &&var_or_dummy = modify? static_cast<A&&>( my_A )
: static_cast<A&&>( static_cast<A>( my_A ) );
(This code doesn't work on my recent GCC 4.6… I recall it working before, but now it always returns a copy.)
On...
hi everyone.
i am trying to use opencv library with code blocks(8.02).i have installed opencv2.1.
when i include the headers and link the library its all fine.i have gone through http://opencv.willowgarage.com/wiki/CodeBlocks tutorial as well.but when i compile the project
it reports no error or warning.it just says exit with status 1.
...