Thanks ralu, I'm using a language very similar to C but which has an abs function that is overloaded for many types.
Anyway, I found a solution:
if(abs(a - (ctr % 32)) <= threshold)
...
Type: Posts; User: C+/-
Thanks ralu, I'm using a language very similar to C but which has an abs function that is overloaded for many types.
Anyway, I found a solution:
if(abs(a - (ctr % 32)) <= threshold)
...
Hi there,
I have a float called counter that goes from 0 to 31 and then back to 0. I want to be able to specify a number x (0-31) and a threshold th, and check if the number is within th units...
Hello there,
This is my situation: I have a solution with several projects. Most of these projects depend on a certain library that is installed in a direction on a higher level than the solution...
Hello, I'd like to know how I can cleanly terminate my C++ console application under windows.
I have a while(true) loop in my code, that keeps polling and Sleep()'ing forever. When I click the...
Thanks mats, but I need a method where the output producing code is unaware of the indents. I guess that's not possible.
Hello,
Is it possible to tell cout that from now on, all output must be indented with n spaces?
For example:
cout << "blahblah" << indent(3) << endl;
cout << "abc" << endl;
cout << "123" <<...
Thanks, matsp!
I knew about the 1 jan 1970 thing, but somehow it didn't occur to me when debugging this problem.. Thanks for pointing that out.
I have a string with the following contents: "1950-01-01 00:00:00".
I have the following code. It should create a time_t object from the string. But it crashes and I don't understand why..
tm...
Was searching for the problem for hours, and then minutes after I posted I found the problem. Sorry about that.
The problem was that I had a subclass pointer pointing to a base class instance. I...
Hello,
I have a problem with an std::string that is a member of a class.
It is simply declared in the public section of my class like this: "string s;". The class is does not have a cpp file...
Thank you :)
So this is ok?
getIPStr(SystemID systemID)
{
stringstream ss;
ss << "SystemID: " << systemID
<< "IP: " << (net->getSystemAddress(systemID)).ToString(true);// << endl;
Hello, I have several cout statements in my code, that all have to print similar strings.
Example:
std::cout << "WARNING: corrupt CHARACTER_LIST_REQUEST packet received from: \n"
...
Nevermind, I've solved it. Sorry
Solution:
using boost.bind:
bind(eventFunction, loginServer, _1, _2, _3)(data, dataLength, sourceSystem);
I have the following problem:
Thanks, brewbuck. I'll go with the class hierarchy.
One last question, though. Does the template method you where thinking about require the user of the library to create his own subclasses? If...
I'm not sure. I don't understand what you mean by "opaque pointer". What is an opaque pointer in this context?
Also, in order for the library to pass an object to the callback, it has to store it....
I've written the library myself, so it's relatively easy to change.
The exact prototype is:
void setEventFunction(MessageID messageID, PacketHandler packetHandler);
where PacketHandler is:...
I'm using a library where to I can pass a function pointer which is later called by the library. I would like to be able to pass a pointer-to-member instead of a normal function pointer to the...
Hmm, I guess the strncpy_s makes it non-portable? Do you have a suggestion for a portable and safe alternative?
The return value indicates what to do with the packet that fired the event. I want...
Thanks, how about this:
I've changed the packet format a bit. The first byte is still the message type, then followed by 6 characters for the account number, followed by 1 to 20 characters for the...
I'm doing some network programming, and I'd like you to review a small piece of code. I want to know if this is safe (regarding bufferoverflows and other security risks).
I'm getting an unsigned...
Thanks for the super fast replies, guys. I'll follow vart's (and others') advice.
Hello, I'd like to know if it is considered bad practice to include a header (.h) in another header. Is it? Why?
I'd like to know if compilers can optimize the following code. I'm interested in MSVC++ and g++.
class Base
{
virtual void doSomething() = 0;
};
class Derived : public Base
Hi,
This is a Windows/VC++ specific question. Is it possible to replace a dll with a new version of that dll, if the dll is linked to an application with an import library? I don't want to have to...