I'm currently reading the Boost.Program_options tutorial.
Here is some of the code they introduce:
// Declare the supported options.
po::options_description desc("Allowed options");
desc.add_options()
("help", "produce help message")
("compression", po::value<int>(), "set compression level")
;
I understand the purpose behind ...
Check the following code:
string toLowerCase(const string& str) {
string res(str);
int i;
for (i = 0; i < (int) res.size(); i++)
res[i] = (char) tolower(res[i]);
return res;
}
class LeagueComparator
{
public:
bool operator()(const string& s1, const string& s2)
{
return toLowerCase(s1) < toLower...
Hi. I'm practising with C, writing simple programs. The little program below should just get 3 numbers from the user and multiplicate them. My problem is that i'm a bit confused about the variable type i must use. I want the program to take any number such as 5, 5.673434, 99.123 and so, calculate with them and print out a rounded flo...
Hey guys, this is my first post on here so please bare with me.
I'm doing a project for school have to incorporate a form of GUI. Sadly, I have no experience with GUIs whatsoever so I just spend the last few hours comparing the various toolkits and settled on FLTK for it's lightweightness. I also spent the time attempting to install FLT...
I have a class A where I construct an object of class B named bb.
After constructing the object bb, I run in to a exception in Class A code which is caught by an exception handler.
Now my question is how to deallocate the memory of object B in the exception handler?
...
Hi All,
I need to get an automation macro like thing within our desktop application. The desktop app will probably be in VB.NET or C#.net.
The reason is to enable the user to record and replay certain tasks that they'd like to automate. Something like macros within office apps and visual studio.
The first thing that comes to my mind is ...
Hi, there!
I'm writting graph classes. I've wrote such code in "Graphs.h" :
#include <vector>
#include <iostream>
using namespace std;
struct Edge{
int v,w;
Edge(int v=-1, int w=-1):v(v),w(w){}
};
class Graph
{
protected:
int Ecnt, Vcnt; bool digraph;
public:
Graph(int V, bool isDirected) :Ecnt(0),Vcnt(V),digraph(isDirected) {}
~...
Hi all, let's say I want to instantiate a different type of object depending on certain circumstances, so i would instantiate them inside the body of an if statement. The problem is if you want to use that object later, you need to declare it before instantiation. How does one declare a generic object. Is there something similar to th...
Hello, maybe someone knows a good crossplatform particle library?
I know Pyro particle library, but it's not crossplaftorm and free. There is also Magic Particles (Probably, the best version I need) but there is only theoretical possibility to make a port on Linux.
...
class C
{
public:
C() : arr({1,2,3}) //doesn't compile
{}
/*
C() : arr{1,2,3} //doesn't compile either
{}
*/
private:
int arr[3];
};*/
I believe the reason is that arrays can be initialized only with = syntax, that is:
int arr[3] = {1,3,4};
Questions
How can I do what I want to do (that
is, initialize an array in a
...
Hi,
I wrote a code in C/C++ which forks a child process, duplicates the stdin/stdout into a pipe ends and calls execvp.
Everything is working fine (i.e. the output from stdin/err/out is captured by the parent process)
The problem is that the child stdout is buffered.
so if the child code looks like this:
printf("Enter any key and hi...
Hi everybody!
I am searching for C/C++ library for txt -> odf conversion. I've already checked http://odftoolkit.org but it has only Java version. Main criterion is a ease of use.
...
I am using perl module HTML::DOM (link to CPAN) for building HTML DOM tree from HTML code and then changing it using standard DOM's removeAttribute, removeChild, innerHTML, createElement and so on.
But, I have found out it's really, really slow and eating too much memory (it's fully in perl, anyway). So, I thought that there will be som...
I once saw this nice little snippet of code below, here at SO:
template<typename to_t, typename from_t>
to_t lex_cast(const from_t &arg) {
to_t ret;
std::stringstream os;
os << arg;
os >> ret;
return ret;
}
This mimics boost::lexical_cast. Usage:
string tmp = ::lex_cast<string>(3.14);
However, due to the default...
This compiles and runs ok on Visual C++ 2010 Express but it only checks against the [2] element: "Fish".
int main()
{
vector<string> words;
string temp;
vector<string> disliked(3);
disliked[0] = "Broccoli";
disliked[1] = "Mushrooms";
disliked[2] = "Fish";
while (cin >> temp)
...
Hi
Can anyone tell me what are the debugger(s) available for c++ language.
Also please provide details about those debugger or reference to get details for the same.
Thanks,
-Pravin
...
C++03 §4.2 N°1:
An lvalue or rvalue of type “array of N T” or “array of unknown bound of T” can be converted to an rvalue of type “pointer to T.” The result is a pointer to the first element of the array.
What has been confusing in this statement for a long time for me was that I didn't quite understand what an rvalue of array type woul...
I'm making a simple windowed game and I want a standard system cursor instead of SDL's black one. Is this possible without manual creation of cursor?
...
I have a function like:
// string is a null-terminated char array. Replace all a in the string with b
void ReplaceCharInString(char *string, char a, char b)
{
// loop over the string char by char, to find all "a"s and replace them with "b"
}
I'm doing the defensive programming. The problem is the implementation replies on the client t...
#define SwapByte4(ldata) \
(((ldata & 0x000000FF) << 24) | \
((ldata & 0x0000FF00) << 8) | \
((ldata & 0x00FF0000) >> 8) | \
((ldata & 0xFF000000) >> 24))
What does that 0x000000FF represent? I know that decimal 15 is represented in hex as F, but why is it << 24?
...