Given a string consisting of a single character followed by a number (one or two digits), I would like to split it into a character and an integer. What is the easiest way to accomplish this?
My thoughts so far:
I can easily grab the character like so:
string mystring = "A10";
char mychar = mystring[0];
The hard part seems to be gra...
What is the warning level you use while compiling QT projects?
When I compiled with W4, I'm getting a lot of warnings such as:
C4127: conditional expression is constant
Should I compile at W3, or find other ways to handle warnings at W4, such as: adding a new header file and using pragma's(mentioned here C++ Coding Standards: 101 Rul...
Like this question already asked, I'd like to initialize a container using STL where the elements are hard-coded in the cleanest manner possible. In this case, the elements are a doubly nested container:
set<vector<int> > A;
And I'd like (for example) to put the following values in:
A = [[0,0,1],[0,1,0],[1,0,0],[0,0,0]];
C++0x fine...
I am currently trying to fix a bug in a proxy server I have written relating to the socket select() call. I am using the Poco C++ libraries (using SocketReactor) and the issue is actually in the Poco code which may be a bug but I have yet to receive any confirmation of this from them.
What is happening is whenever a connection abruptly ...
Hello all,
my question is stated in the title. How exactly do I do that?
I have an open connection and I want to "hijack" it and send my custom messages through it. From my understanding that is done with sockets and their handlers.
Any language would do but C#.NET is preferred.
Thank you
UPDATE: What exactly am I trying to achieve...
In C++ whats the difference between
char const *ptr=&ch;
and
const char *ptr=&ch;
...
So I have the following HTML and am trying to change which item is selected.
<select name="coolselectbox">
<option value="default" selected="selected">---</option>
<option value="something">Something</option>
<option value="something-else">Something Else</option>
</select>
Here's what I've tried:
QWebElement defaultOpt =
...
Hey guys,
I'm currently working on a C++ project, where dynamic arrays often appear.
I was wondering, what could be the correct way to initialize a dynamic array using the new-operator? A colleague of mine told me that it's a no-no to use new within the constructor, since a constructor is a construct that shouldn't be prone to errors or...
I'm wondering about Nvidia's CUBLAS Library. Does anybody have experience with it? For example if I write a C program using BLAS will I be able to replace the calls to BLAS with calls to CUBLAS? Or even better implement a mechanism which let's the user choose at runtime?
What about if I use the BLAS Library provided by Boost with C++?
...
//sample.h
int calci(int &value)
{
if(value < 20)
throw value;
else
return value;
}
class XYZ
{
int m_x;
public: XYZ(int &x)try:m_x(x-calci(x))
{
}catch (int &a)
{}
};
class ABC
{
int m_a;
public: ABC():m_a(0)
{
}
void foo()
{
XYZ xyz(10);
}
};
in...
I want to have two options for the program to work on, the start address and end address so that the program options are as follows:
--start_address 0xc0000000 --end_address 0xffffffff
Is it possible for options_description to take such hex input? Do I have to consider the input as string and convert them to hex values. I have this at...
hi,
I have a vec_A that stores instances of class A as: vec_A.push_back(A());
I want to remove some elements in the vector at a later stage and have two questions: a) The element is deleted as: vec_A.erase(iterator) Is there any additional code I need to add to make sure that there is no memory leak? .
b) Assume that condition if(...
We have a software product in c++, that due to documented problems with the compiler generates faulty code (Yes I know it is horrible in itself). This among other bugs causes Access Violations to be thrown.
Our response to that is to catch the error and continue running.
My question is, is this a responsible approach? Is it responsibl...
In some library I'm using (written in C) its
StorePGM(image, width, height, filename)
char *image;
int width, height;
char *filename;
{
// something something
}
All functions are defined this way. I never seen such function definitions in my life. They seem to be valid to MSVC but when I compile it as C++ it gives errors.
What is ...
Hello Everyone,
This time i want to implement Sphinx in C++ application in Linux. Please give me the API required to do the same or the concerned link will also do. Although i found many for PHP, however none for C++.
I have also used GTKmm in my application.
Thanks in advance.
...
For example, i downloaded Gecko 1.9.1 SDK.
It contains js3250.dll.
How i can be sure that this dll is thread-safe?
Advance Thanks
-Parimal Das
...
class MyClass
{
public:
void setVar(const char *str);
private:
std::string mStr;
int maxLength; //we only store string up to this length
};
What's the best approach to implement setVar when the external code is quite likely to pass in NULL for an empty string (and cannot be changed)? I currently do something a bit like:
void M...
Error 38 error C2660: 'malloc' : function does not take 1 arguments C:\VolumeRenderer\render.cpp 296 1 VolumeRenderer
Error 39 error C2660: 'malloc' : function does not take 1 arguments C:\VolumeRenderer\render.cpp 412 1 VolumeRenderer
Error 40 error C2660: 'malloc' : function does not take 1 arguments C:\VolumeRenderer\render.cpp 414 1 ...
Hi All,
I am using MSXML2 for XML Parsing. I am using IXMLDOMNodePrtr , IXMLDOMDocumentPtr ans so on for XML Parsing. I have observed that while my application ends Private Bytes usage of EXE is say 30 MB and it keep on reducing. Previously i was thinking that their might be some memory leaks there. I have different tolls for the same a...
I have a c++ program in which a gdk-pixbuf is created. I want to output it as an image, so I call gdk_pixbuf_save_to_stream(pixbuf,stream,type,NULL,&err,NULL). This works fine when "type" is png or tiff, but with jpeg or bmp it just produces a black square. The original pixbuf consists of black-on-transparent (and gdk_pixbuf_get_has_a...