Firstly, sample codes:
Case 1:
typedef char* CHARS;
typedef CHARS const CPTR; // constant pointer to chars
Textually replacing CHARS becomes:
typedef char* const CPTR; // still a constant pointer to chars
Case 2:
typedef char* CHARS;
typedef const CHARS CPTR; // constant pointer to chars
Textually replacing CHARS becom...
I have some C++ code that I found that does exactly what I need, however I need it in C and I do not know how I could do it in C, so I am hoping someone can help me out.
The C++ code is:
std::string value( (const char *)valueBegin, (const char *)valueEnd );
This is using the string::string constructor:
template<class InputIterator> ...
Some C++ compilers permit unnamed unions and structs as an extension to standard C++. It's a bit of syntactic sugar that's occasionally very helpful.
What's the rationale that prevents this from being part of the standard? Is there a technical roadblock? A philosophical one? Or just not enough of a need to justify it?
EDIT: Sorry, ...
I previously asked this question under another name but deleted it because I didn't explain it very well.
Let's say I have a class which manages a file. Let's say that this class treats the file as having a specific file format, and contains methods to perform operations on this file:
class Foo {
std::wstring fileName_;
public:
...
Hi,
I would like to know if there is a way to embed Mercurial tags into my C/C++ code.
Basically I would like the tag string, which will end up being a release number (major.minor.rev), to be automatically inserted in a determined location of my C code as a static string.
The overall objective is that the application could be querie...
I'm making a game and I have a vector of bullets flying around. When the bullet is finished, I do bullets.erase(bullets.begin() + i); Then the bullet disappears. However it does notseem to get rod of the memory. If I create 5000 bullets then create 5,000 more after those die off, memory stays the same, but if I create 5,000 more while th...
Oh C++ gurus, I seek thy wisdom. Speak standardese to me and tell my if C++ guarantees that the following program:
#include <iostream>
using namespace std;
struct A
{
A() { cout << "A::A" << endl; }
~A() { cout << "A::~" << endl; }
};
struct B
{
B() { cout << "B::B" << endl; }
~B() { cout << "B::~" << endl; }
};
struc...
Hi to all,
i've encountered a little problem that i can't find answer to, so i hope to find someone here to help me.
So this is the problem. I have a buffer with real numbers (float) that i need to draw on my scope. I implemented a class that can draw integers only and i really don't know how to do that with float numbers as i don't kn...
Alchemy allows users to compile C and C++ code that is targeted to run on the open source ActionScript Virtual Machine (AVM2). While this idea seems really promising has anyone had success with this - if so are there examples?
I was wanting to convert some old DOS programs to SWF so they could be ran in the browser.
...
Hi
How I can get in C++ random value from 01 to 12?
So I will have 03, or 06, or 11?
...
Hi,
Can anybody elaborate the Bridge design pattern and the Decorator pattern for me. I found it similar in some way. I don't know how to distinguish it?
My understanding is that in Bridge, it separate the implementation from the interface, generally you can only apply one implementation. Decorator is kind of wrapper, you can wrap as ...
Hello,
I'm working with CMake, and my program compiles fine with g++. However, I also wish to compiled it with bcc32 and cl.
I am running into an issue -- I'm telling cmake to use those compilers by doing a command line somewhat like "cmake -DCMAKE_CXX_COMPILER=cl" or whatnot, and it picks up the compiler correctly (ie, in that case, t...
When using a simple encryption method in which the letters are replaced by the indexing numbers of the alphabet, there are multiple ways of decrypting them, ex. ABOR is 121518 but 121518 could also be AYEAH or LAER.
Well I need an algorithm to calculate how many possible ways there are for a given number to decrypt the message via the ...
Hi all ,
This is my second problem today, pointers are giving me nightmares .
I'm trying to make a program that do the same thing that strcpy() function do..
Once i try it..it crashes and i'm 100% sure that's a pointers issue in my code. I think because there is some sort of an unintiallized pointer(*copied) ..But i've assigned NULL to i...
I have a C++ console program which I can compile using glut or freeglut and get the same undesirable behavior. Specifically, if I "start with debugging" everything is fine, but if I start without debugging I have to manually switch to the window. Is there any way to force the GLUT window to the foreground on program start?
...
Hi All,
I am inspired to start programming some things in OpenGL, using c++.
Can anyone list here what tools should be installed to start this process.
Ie
IDE
Compiler
OpenGL download etc?
Thanks
...
Does anyone have a favorite boost random number generator and can you explain a little on how to implement it into code. I am trying to get the mersenne twister to work and was wondering if anyone had preference towards one of the others.
...
I have Qt 2009.05 and Qt VS Add-in 1.1.3 installed on my computer with Visual Studio 2008. When I create simple Qt Application and build it, I'm receiveing this error.
1>LINK : fatal error LNK1181: cannot open input file 'qtmain.lib'
When I searched whole disk this file to add in Visual Studio library include variable, I doesn't find....
I am preparing myself for programming competitions and i would like to know how can i solve this problem. I guess it's geometry problem, and it seems i can't get any ideas about solving it.
Here it is:
There is a yard in which there are wolves and sheep. In the yard there are also blocks which do not allow to pass. The wolves are repr...
I know that there is the /proc/proc#/maps file that shows the libraries that are loaded, but is there a way to find out in which order the symbols are loaded?
...