typedef unsigned char Byte;
...
void ReverseBytes( void *start, int size )
{
Byte *buffer = (Byte *)(start);
for( int i = 0; i < size / 2; i++ ) {
std::swap( buffer[i], buffer[size - i - 1] );
}
}
What this method does right now is it reverses bytes in memory. What I would like to know is, is there a better way to g...
Hi,
I'm trying to run msbuild on a solution that has some C++ code in it.
I have the SDK installed but not Visual Studio.
I get the following error:
error MSB3411: Could not load the Visual C++ component "VCBuild.exe". If the component is not installed, either 1) install the Microsoft Windows SDK for Windows Server 2008 and .NET Framew...
If I have a code like this:
struct A {
virtual void f(int) {}
virtual void f(void*) {}
};
struct B : public A {
void f(int) {}
};
struct C : public B {
void f(void*) {}
};
int main() {
C c;
c.f(1);
return 0;
}
I get an error that says that I am trying to do an invalid conversion from int to void*. Why can't compiler...
Hi,
I'm having issues with a very strange error in some code I wrote.
The basic idea behind the code can be trivialised in the following example:
template <class f, class g> class Ptr;
template <class a, class b, class c = Ptr<a,b> >
class Base
{
public:
Base(){};
};
template <class d, class e>
class Derived : public Base <d,...
Writing a program in c++ and I want to issue a system command from the system() function but I don't want the user to see the command (because the command includes a pwd) in the executable window. I need to copy a file from the user's directory onto the server without allowing user access to the server or displaying the pwd. Figured ha...
I'm currently working on cross-platform applications and was just curious as to how other people tackle problems such as:
Endianess
Floating point support (some systems emulate in software, VERY slow)
I/O systems (i.e. display, sound, file access, networking, etc. )
And of course, the plethora of compiler differences
Obviously this i...
How do I format my output in C++ streams to print fixed width left-aligned tables? Something like
printf("%-14.3f%-14.3f\n", 12345.12345, 12345.12345);
poducing
12345.123 12345.123
...
Hi there,
I'm pretty inexperienced using C++, but I'm trying to compile version 2.0.2 of the SBML toolbox for matlab on a 64-bit XP platform. The SBML toolbox depends upon Xerces 2.8 and libsbml 2.3.5.
I've been able to build and compile the toolbox on a 32-bit machine, and it works when I test it. However, after rebuilding it on a 64-...
I have a loop written in C++ which is executed for each element of a big integer array. Inside the loop, I mask some bits of the integer and then find the min and max values. I heard that if I use SSE instructions for these operations it will run much faster compared to a normal loop written using bitwise AND , and if-else conditions. M...
Hi there,
I've got a problem with my terrain engine (using DirectX).
I'm using a vector to hold the vertices of a detail block.
When the block increases in detail, so the vector does.
BUT, when the block decreases its detail, the vector doesn't shrink in size.
So, my question: is there a way to shrink the size of a vector?
I did try t...
When reading files off of a hard drive, mmap is generally regarded as a good way to quickly get data into memory. When working with optical drives, accesses take more time and you have a higher latency to worry about. What approach/abstraction do you use to hide/eliminate as much latency and/or overall load time of the optical drive as p...
I am writing a C++ DLL that is called by an external program.
1.) I take an array of strings (as char *var) as an argument from this program.
2.) I want to iterate through this array and call a COM function on each element of the string array. The COM function must take a BSTR:
DLL_EXPORT(void) runUnitModel(char *rateMaterialTypeName...
So I'm almost done an assignment involving Win32 programming and sockets, but I have to generate and analyze some statistics about the transfers. The only part I'm having trouble with is how to figure out the number of packets that were sent to the server from the client.
The data sent can be variable-length, so I can't just divide the ...
Simple question: are the following statements equivalent? or is the second one doing more implicit things behind the scenes (if so, what?)
myClass x(3);
myClass x = myClass(3);
Thanks!
...
"va_end - Macro to reset arg_ptr".
After accessing a variable-argument list, the arg_ptr pointer is usually reset with va_end. I understand that it is required if you want to re-iterate the list, but is it really needed if you aren't going to? Is it just good practice, like 'always have default: in switch'?
Edit: Answered by greyfade, t...
I'm writing some software that automatically connects a Bluetooth device using the Windows Bluetooth API. When it connects, Windows automatically starts installing the Bluetooth HID device driver, as expected:
This takes about 10-15 seconds, after which Windows displays the familar "ready for use" message:
The problem is that Bluet...
When using iostream in C++ on Linux, it displays the program output in the terminal, but in Windows, it just saves the output to a stdout.txt file. How can I, in Windows, make the output appear in the console?
...
in an example i saw this line
Thing *pThing = new (getHeap(), getConstraint()) Thing(initval());
There was no explanation, function body or class definition. What does the 2nd parameter mean?
...
On Windows, clock() returns the time in milliseconds, but on this Linux box I'm working on, it rounds it to the nearest 1000 so the precision is only to the "second" level and not to the milliseconds level.
I found a solution with Qt using the QTime class, instantiating an object and calling start() on it then calling elapsed() to get t...
Trying to compile a sample http class with the SDK, and getting some strange link errors... I am sure its something to do with a missing option, or directory...
I am no expert in c++ as you can see, but looking for any assistance.
I included my sample class. I also did install the Windows SDK. If you need any other information about ...