inputs:
arbitrary bitset, e.g. bit positions 012345
arbitrary bit mask, e.g. (x=1) xx0x0x
output:
xx0x1x2345
That is, I want the first bit of the bitset to be placed in the first 0 of the mask. Likewise, the second bit is placed in the second 0 of the mask.
example:
mask = 1001001
bits = 1101
result = 1111011
I know that this ...
Using ALSA to play audio, after calling snd__pcm__writei, can I free the sound sample buffer right away or do I need to wait until the sound is finished playing before I can free the sample buffer?
For example:
unsigned short *buffer;
buffer = malloc(size of sample to play);
...load data into buffer...
snd_pcm_writei (playback_handle,...
Trying to figure out why my list() class pointers are being overwritten with the third node. What happens in the insert function (below) is that the third time the insert function is called my "headByName->nextByName" node pointer is overwritten by the third node, when it should point to the second. So as you can guess the 4th node is ov...
I remember I had some app the launched other applications and placed them in tabs in it's form without the titlebars.
I wonder how can that be done?
Preferably with C# but if it's not possible/too hard within .NET C++ is fine too.
Thanks.
...
I'm just wondering how
void test()
{
const static int ABC = 12;
cout << ABC;
}
is different from
void test()
{
const int ABC = 12;
cout << ABC;
}
if this function is repeatedly called while the program is executing? What I mean is, is there any performance difference? Or is there a reason why you should prefer one over...
Is it legal?
class SomeClass {
public:
static void f();
};
using SomeClass::f;
Edit: I forgot to qualify function. Sorry.
...
I have a base class A and a derived class B:
class A
{
public:
virtual f();
};
class B : public A
{
public:
B()
{
p = new char [100];
}
~B()
{
delete [] p;
}
f();
private:
char *p;
};
For any reason the destructor is never called - why? I dont understand this.
...
I have the following string in notepad "ùŒÚÿwž+2»ó66H".
I used the fstream library to read those files in c++ and print those characters and thier equivalent decimal numbers in the conlsole window but the symbols are different than those in notepad and numbers for the extended characters are in negative form,i realize maybe its impossib...
Is it possible to share references to C# objects between C# and C++ code without massive complexity? Or is this generally considered a bad idea?
...
Where can I find an efficient algorithm for breaking lines of text for formatted display?
...
test.c:
int main()
{
return 0;
}
I haven't used any flags (I am a newb to gcc) , just the command:
gcc test.c
I have used the latest TDM build of GCC on win32.
The resulting executable is almost 23KB, way too big for an empty program.
How can I reduce the size of the executable?
...
Hi!
I'm trying to figure out a way to globally override malloc and related functions in visual c++ (2005). My setup is a dll with statically linked runtime library that consists of both my own c++ code, external c++ and c code. What I want to accomplish is to allow a user of the dll to set their own implementations of the memory allocat...
Hi,
I have run into some bugs into one of the boost components that I am using. After analyzing the problem a bit, I've found that I was not the only one, and the author had already issued a fix that is available in the boost SVN trunk.
What would be the best approach if I wanted to update just this component and reuse the libraries th...
Trying to create a an image acquiring application optimized for a fast scanner (which can provide up to 6 compressed images [color+gray+binary][front+rear] for each paper at speed of 150 ppm) I have some speed issues.
Using TWAIN technology and memory buffer transfer mode (TWSX_MEMORY) I receive image buffer (as JPEG or TIFF file loade...
Hi,
I am facing an issue with recv() and send() winsock api. Recv() hangs while receving the last packet.
Problem Description:-
System A's app is writing data over a non-blocking socket and system B's app is receiving data over a blocking socket in chunks of 64k.
It seems that while reading probably the last packet of 64k, which may ...
Hi,
I'd like to know if there's a tool which allows you to do class definition based on an XML format. I'm not looking for data binding. Anyone can help ?
Thanks
...
I've written a program in Qt Creator 1.0.0 (Qt version 4.5.0) where at the beginning of main() function I've put
srand(time(0));
Then I'm calling rand() from another thread (subclass of QThread). In that function, rand() is producing same sequence of numbers each time I'm running the program. Why is this happening?
Thanks in advanced...
I'm working with an API that is delivered to customers as a static library.
This library in turn makes use of another 3rd party library built with the Intel Compiler. This library has dependencies to some Intel libraries that I don't possess. When I build a test application I get past this by specifying these libraries in the "Ignore spe...
I'm having trouble storing instances of my smart pointer into a container. Here is the code for the pointer.
#include "std_lib_facilities.h"
template <class T>
class counted_ptr{
private:
T* pointer;
int* count;
public:
counted_ptr(T* p = 0, int* c = new int(1)) : pointer(p), count(c) {} // default constructor
expli...
hi,
i have done up a program which requires the following:
1) prompts user input account no
2) prompts user input account type
2.1) if account type = a, prompts some input and does a certain formula [if]
2.2) if account type = b, prompts some input and does another formula [else if]
2.3) if account type is wrong(not a or b), promp...