Hi,
I want to "mix" char* data in this form:
source = (source + some_primary_number) % 256;
--the 256 line is because of I need to keep the range of char.
so I can do the "mix" and "un-mix" in 2 functions - the implementation above is for the mixing and this one is for the un-mixing:
source = source - some_primary_number;
if ( so...
I have tried clock_gettime(CLOCK_REALTIME) and gettimeofday() without luck - And the most basic like clock(), what return 0 to me (?).
But none of they count the time under sleep. I don't need a high resolution timer, but I need something for getting the elapsed time in ms.
Thanks.
EDIT: Final program:
#include <iostream>
#include <...
does this work on string in c++?
string s="lomi";
cout<<s<<endl;
what is bad in this code?
#include <iostream>
#include <cstring>
using namespace std;
int main(){
string s=string("lomi");
for (int i=0;i<s.length();i++){
s[i]= s[i]+3;
}
std::cout<<s<<std::endl;
return 0;
}
?
...
Trying to dive into Qt big time but haven't done a large project with it yet. Currently using Python, but I've been thinking -- which is really the better language to use in terms of programmer productivity?
In most comparisons between the languages, Python is the obvious answer, because you don't have to mess with memory management and...
I've started doing my own "struct of arrays" coding, but wondered if anyone knew of libs or templates that were already out there for doing intense data transform stuff on memory constrained hardware.
I suppose what I'm looking for is a sort of "in memory" container that allows me to queue up insertions until a sync point, and mid itera...
Hi,
During destruction of the derived class object, i first hit the derived class destructor and then the base class destructor (which is as expected). But i was curious to find out - at what point does the functions of the derived class go out of scope (are destroyed).
Does it happen as soon as the control leaves the derived class des...
I've seen various questions here on SO involving Microsoft's XML documentation tags, but I'm having trouble adding some example code:
/// <summary>Return the oldest acceptable timestamp for a data packet.</summary>
/// <example>
/// if( GetOldestValidResultTime() < lastResultTime )
/// {
/// Console::WriteLine("Results are too old")...
Thank you so much for helping me! Everyone is so fast and excellent! Thanks again!
What is happening is no data is being written to my file, after I test this code. Just a 0 appears.
What am I doing wrong?
void CreateHtmlFile(string myMessages[])
{
int i = 0;
int emptyarray = 0;
int myEmptyCounter = 0;
int emptyArrayCounter = ...
I have a class that is used as a member in many places in my project.
Now, instead of this class I want to have a polymorphism, and the actual object will be created by some kind of factory.
I have to choose between:
Having to change all the places where I use the class - to call the factory and use a pointer instead of object directl...
EDIT BEFORE YOU READ: Sorry.. I didn't add newline so it appeared jumbled, I can't delete the question because I'm not registered yet, sorry for wasting your time guys.
I just used a template for the first time (for finding MIN of two numbers) instead of a macro, and I liked it! But when I tried to modify and make my own template it fai...
Hello
I want to create process with low integrity level from process with medium integrity level.
I found msdn example: Designing Applications to Run at a Low Integrity Level
But it does not work on my system. Process is created successfully, but message box
"Alpplication failed to initialized properly(0xC0000022 -- STATUS_ACCESS_DE...
I'm having a problem which I'm sure is simple to fix but I'm at a loss...
I have a template that performs the following code:
T value = d;
if ( std::numeric_limits< T >::is_signed )
{
if ( value < 0 )
{
*this += _T( "-" );
value = -(signed)value;
}
}
Now for, obvious reasons, GCC is giving me a warning...
I set up a (perhaps very unscientific) small test to determine the overhead of virtual functions in a one-level single inheritance and the results I got were, well, exactly the same when accessing the derived class polymorphically or when accessing it directly. What was a bit surprising was the order of magnitude of computation time that...
The following class contains some members of the same type:
template <typename T>
class MyClass
{
T m0;
T m1;
T m2;
T m3;
T m4;
//...
};
The members are all declared without an intervening access-specifier and thus are allocated that later members have higher addresses (ISO/IEC 14882: 9.2.12). The same paragrap...
I have a very strange question.
I have a class/function :
class MCBSystem {
[...]
template <class Receiver>
void setCallBack(int i, Receiver* receiver, void(Receiver::*function)(void*)) {
iCallBacks.at(i) = new CallBack<Receiver>(receiver, function, this);
};
};
And I inherit it (multiply) in another class :...
I "learned" C++ at school, but there are several things I don't know, like where or what a compiler can optimize, seems I already know that inline and const can boost a little...
If performance is an important thing (gaming programming for example), does putting class attributes not public (private or protected) allow the compiler to ma...
AFAIK, reduce the number of sub classing means you don't actually code the class statically but you create the object with different properties in order to avoid create many subclass.
class carPrototype : public prototype
{
prototype* clone();
};
Yon doesn't require to create a class called sedanCarPrototype, superCarPrototype but j...
In Qt Source files, there are two versions of header files, such as:
qxmlstream.h
qxmlstream_p.h
Why are there _p.h files?
...
I just started with pthreads and don't know much about it. I was trying to set the priorities of pthreads using pthread_setschedprio() but it returns "EINVAL". Here is my code:
#include <pthread.h>
#include <errno.h>
void *Run(void *ptr);
class Thread {
public:
pthread_t myPthread;
void start() {
pthread_create( &myP...
This is my code (simplification of a real-life problem):
class Foo {
public:
void f(const string& s) {
if (s == "lt") {
return lt();
} else if (s == "lte")
return lte();
} else if (s == "gt")
return gt();
} else if (s == "gte")
return gte();
}
}
void lt() { /* skipped */ }
void lte() {...