c++

Segmentation Fault?

Hello, when I run this program while inputting a number greater than 46348, I get a segmentation fault. For any values below it, the program works perfectly. I am using CodeBlocks 8.02 on Ubuntu 10.04 64-bit. The code is as follows: int main() { int number = 46348; vector<bool> sieve(number+1,false); vector<int> primes; ...

How to use QMetaMethod with QObject::connect

I have two instances of QObject subclasses and two QMetaMethod instances of signal in one of objects and slot in another object. I want to connect this signal and slot with each other. I've looked through the qobject.h file and find that SIGNAL() and SLOT() macro are just add "1" or "2" character to the beginning of method signature so ...

windows keydown listeners in C

I am having a very hard time finding resources that talk about the windows message system. Mainly the keydown constant variables. I need to know what const varibles I need to listen for all keypress especially the arrow keys for C ...

C++ includes with and without .h

Possible Duplicate: What is the difference between using #include<filename> and #include<filename.h> in c++ I've never noticed it making any difference whether or not I include the .h at the end of an include, so I've always ignored the meaning, but I've just noticed in a particular program of mine, I get the error "memcpy was...

x86-64 long double precision

hello. What is the actual precision of long double on Intel 64-bit platforms? is it 80 bits padded to 128 or actual 128 bit? if former, besides going gmp, is there another option to achieve true 128 precision? ...

Load XML from string in libxml++ in C++

Does anyone familiar with libxml++ know if it's possible to load the XML document from a string instead of a file? Alternately, if it can load a document directly from a web page, that would do. Thanks ...

What C++ library do I need to get this program to compile

When I try to compile my program I get these errors: btio.c:19: error: ‘O_RDWR’ was not declared in this scope btio.c:19: error: ‘open’ was not declared in this scope btio.c: In function ‘short int create_tree()’: btio.c:56: error: ‘creat’ was not declared in this scope btio.c: In function ‘short int create_tree(int, int)’: btio.c:71: e...

Is compiler able to do a procedural integration of functions imported from dll?

I know, that modern compilers can do procedural integration not only with functions defined inline, but also with functions residing in object files. But is this also true when you compile your program against shared library (especially dll)? Roughly speaking: will function code be copied into executable from dll, if that's desirable? ...

How to traverse a Btree?

I have a Btree and I'm trying to figure out how traverse it so that the keys are displayed ascending order. All I can figure out is that this can be done with a recursive function. What's the pseudo-code to do it? ...

Canny edge detection - grayscale images always coming up as 3-channel, unusable?

I am working through the book "Learning OpenCV" from the O'Reilly series and am trying to perform a canny edge detection sample. Any grayscale image I choose seems to come up as having 3 channels, and to the best of my knowledge, canny only works with single channel images, so this always fails. I am even using the images provided by...

singly linked list in the C++ standard library or other widely-used libraries?

Seems that there is only doubly linked list (but no singly linked list) in the C++ standard library, right? Is there any widely-used C++ libraries with singly linked list? ...

Sorting 2D array of chars C++

I have a 2d array of chars where in each row I store a name... such as this: J O H N P E T E R S T E P H E N A R N O L D J A C K How should I go about sorting the array so that I end up with A R N O L D J A C K J O H N P E T E R S T E P H E N These is a 2d array of chars..... no strings or char points..... ...

Mac laptop usage and development discussion?

I bought a new Mac book (MacBook Pro), and I am previously using Windows. I use this MacBook for personal (e.g. instant messaging, document, browsing the web) and development (writing C++ and Java code) purpose. Any recommended discussion group or forums (or I can directly ask here in StackOverflow)? I am a newbie. ...

Why does the answer print out twice?

I made a program that returns the product a*b*c where a,b,c are pythagorean triples and add up to 1000. The program does output the correct answer but does it twice. I was curious as to why this is so. After playing around with it a bit I found out that it prints out when a = 200 b = 375 c = 425. And once again when a = 375 b = 200 c = ...

Correct answer will not output

I made a program that returns the sum of all primes under 2 million. I really have no idea what's going on with this one, I get 142891895587 as my answer when the correct answer is 142913828922. It seems like its missing a few primes in there. I'm pretty sure the getPrime function works as it is supposed to. I used it a couple times befo...

Design patterns commonly used for RTOS (VXworks)

Hi, Can anyone help me on design patterns commonly used for RTOS? In VXworks, which pattern is more preferable? ...

shared_ptr as class member

It's common to declared contained objects as a pointers to that class, while "forward declarating" them in header file. This in order to reduce physical dependencies in code. For example class B; // forward declaration class A { private: B* pB; }; Would it be good idea to declare such a member as shared_ptr, instead of ...

Interop c# using a "long" from c++

On my System: sizeof(long) in c++ is 4 aka 32bits sizeof(long) in c# is 8 aka 64 bits So in my Interop method declarations I've been substituting c++ longs with c# int's however I get the feeling this isn't safe? Why is a long the same size as an int in c++? And long long is 64bits? What's next a long long long long?? ...

C/C++ GetAsyncKeyState() Key combination

I understand how to use this function with one key, but how can I use it with two keypresses? Like: GetAsyncKeyStat(VK_LBUTTON && VK_RBUTTON); ...

how to call gstreamer as an external process in Qt to play incoming audio streams?

im now using mplayer to play incoming audio streams from network. i need to use gstreamer to play that. my code to play the audio using mplayer is like this: arg<<"http://192.168.0.2/img/video.asf"&lt;&lt;"-novideo"; program="mplayer"; process=new QProcess(this); process->start(program,arg);## Heading ## ...