I have a short code snippet in C++ and I need to have the same functionality in C#:
typedef enum {eD=0x0, eV=0x1, eVO=0x2, eVC=0x3} eIM;
#define htonl(x) ( ( ( ( x ) & 0x000000ff ) << 24 ) | \
( ( ( x ) & 0x0000ff00 ) << 8 ) | \
( ( ( x ) & 0x00ff0000 ) >> 8 ) | \
( ( ( x ) ...
I need to generate time-stamp in this format yyyymmdd. Basically I want to create a filename with current date extension. (for example: log.20100817)
...
I'm designing a MIPS simulator in c++ and my simplified OS must be able to run stat() occasionally (when a program being executed on my simulator requires an input or an output or something.)
The problem is, I need to be able to assert STDIN, STDOUT, and STDERR as parameters to stat "stat("stdin",buff)" where buff is the pointer to th...
I can't use any mp3 code that is patented by Fraunhofer, so no encoders OR decoders (e.g. ffmpeg, lame, MAD, etc.), plus it's too big.
I am doing this on Windows, but DirectShow's IMediaDet seems to slow down over time, calling it a few hundred times brings my system to a crawl, even re-using the same interface object and just putting ...
After some time mainly .net development, i need to work in c++ in a cross platform manner.
I don't want to give up visual studio, so my hope was that it is possible to use visual studio and the windows target as a testbuild, and then every once in a while through means of a vm test the code on linux or mac.
Does anyone have experience ...
Given a 3D line in CGAL, how do I compute a point on that line that is some known distance from an endpoint?
...
Hi, I'm currently extending an image library used to categorize images and i want to find duplicate images, transformed images, and images that contain or are contained in other images.
I have tested the SIFT implementation from OpenCV and it works very well but would be rather slow for multiple images. Too speed it up I thought I could ...
During a code review I performed today for my colleague, I noticed a function that was defined as returning a boolean value, but in practice it returned only true. In a case of failure, this function threw an exception. I pointed it out and advised to change the return value to void (the code is written in C++). I had no doubt that this ...
Now I have a database, which one field type is an array of byte.
Now I have a piece of memory, or an object. How to convert this piece of memory or even an object to a byte array and so that I can store the byte array to the database.
Suppose the object is
Foo foo
The memory is
buf (actually, don't know how to declare it...
This code compiles and works as expected (it throws at runtime, but never mind):
#include <iostream>
#include <boost/property_tree/ptree.hpp>
void foo(boost::property_tree::ptree &pt)
{
std::cout << pt.get<std::string>("path"); // <---
}
int main()
{
boost::property_tree::ptree pt;
foo(pt);
return 0;
}
But as soon a...
In a multithreaded C++ program, I have the equivalent of this running in one thread:
while(obj->member) { } // waiting for obj->member to be set to false in another thread
and in another thread, obj->member is set to false. Even when it's set to false, however, the loop doesn't break. If I change it to this:
while(obj->member) { Slee...
Does it actually work on some compilers/machines but on others it causes heap corruptions and crashes?
Does anyone have any insight into what going on under the covers?
...
Hi all,
I'm a noob at C++ and MySQL and I only want to retreive a xml file stored as a longblob in MySQL. I did a SELECT query to get the content and after I store this content in a xml file with std::ofstream. With this i get:
<?xml version="1.0" encoding="UTF-16"?> <AnObject noNamespaceSchemaLocation...
instead of this:
<?xml vers...
I am trying to provide users of a class (MyGizmo below) that derives from a variadic hierarchy (ObjGetter below) with a simple, uncluttered way to unambiguously call a member function that takes no arguments (check() below). I can make this work with functions that take arguments (like tune() below) but I have not found a way to make it ...
Hello all.
I'm experiencing a challenging problem, which has not been solvable - hopefully until now. I'm developing my own framework and therefore trying to offer the user flexibility with all the code complexity under the hood.
First of all I have an abstract base class which users can implement, obviously simplified:
class IStateTr...
ok well i have a simple game that uses really high of memory and cpu.
cpu goes over 44% and memory goes over 5000.
here is my code
Code
how to fix this?
EDIT
memory: 5000 bytes.
cpu: 44% on i5
the program get slower by the time it runs.
...
I'm trying to implement this: from https://docs.google.com/viewer?url=http://www.tinaja.com/glib/bezdist.pdf&pli=1
The following BASIC program uses the method of finding distance. The
program also searches for the minimum squared distance between points and
a curve.
REM BEZIER.BAS JIM 20DEC92 12:37
DATA 2,3,5,8,8,14,11,17,14,17,16,...
i basically want to use a dif function to extract a different element of a class (ac).
the code is similar to this:
.h:
class MyClass
{
public:
double f1(AnotherClass &);
void MyClass::f0(AnotherClass & ac, double(MyClass::*f1)(AnotherClass &));
};
.cc:
double MyClass::f1(AnotherClass & ac)
{
return ac.value;
}
void M...
Hi!
for ActionScript there are quite a few "tweening" frameworks to facilitate animating objects. for example TweenLite: http://www.greensock.com/tweenlite/
it allows to animate an arbitrary object with a single line of code:
Pseudocode:
tween(myObject, 3.0f, {xpos:300});
what this line of code does is instanciating a new tweening ob...
I would like to know what are the common memory management issues associated with C and C++. How can we debug these errors.
Here are few i know
1)uninitialized variable use
2)delete a pointer two times
3)writing array out of bounds
4)failing to deallocate memory
5)race conditions
1) malloc passed back a NULL pointer. You need to...