c++

How do shared pointers work?

How do shared pointers know how many pointers point to that object? (shared_ptr, in this case) ...

What is a QT Plugin?

What is a QT Plugin? What are differences between a qt plugin and a custom made qt library? Thanks. ...

C++ sort array of strings

I am trying to sort an array of strings, but it's not sorting anything.... what am I doing wrong? string namesS[MAX_NAMES]; int compare (const void * a, const void * b){ return ( *(char*)a - *(char*)b ); } void sortNames(){ qsort(namesS, MAX_NAMES, sizeof(string), compare); } ...

How to initialise a struct-type in the initialisation list?

How can I initilise a structure in the constructor list? Say: struct St{int x, y}; class Foo { public: Foo(int a = 0, int b = 0) : /*here initilise st_foo out of a and b*/ {} private: const St st_foo; }; ...

advance mathematics c++ libraries

what popular advance mathematics libraries for c++ are present out there, so that they can be used as a 1 stop solution and avoiding reinventing the wheel ? ...

how to convert complex json to somthing i can work with in c++

Hi im using qt , and i parse complex json data structure but i find my self doing to many loops each time i need to parse this JSON , i wander how or what can be the best way to handle big JSON structures ...

C++ stream as a parameter when overloading operator<<

I'm trying to write my own logging class and use it as a stream: logger L; L << "whatever" << std::endl; This is the code I started with: #include <iostream> using namespace std; class logger{ public: template <typename T> friend logger& operator <<(logger& log, const T& value); }; template <typename T> logger& operator <...

Creating a real standalone application for Windows XP with MSVC 2010?

I have a C++ application only taking use of the basic Win32 API (I can remove that too if neccessary) and the C++ STL. I'm using MSVC and want it to be really standalone. I have already tried several options (including using the "Multithreaded" option instead of "Multithreaded DLL"). Yet: It misses several MSVC runtime DLLs on many comp...

C++ Detecting ENTER key pressed by user

I have a loop where I ask the user to enter a name. I need to stop when the user presses the ENTER key..... or when 20 names have been entered. However my method doesn't stop when the user presses the ENTER key //loop until ENTER key is entered or 20 elements have been added bool stop = false; int ind = 0; while( !stop || ind >= 20 ){ ...

Endianness and C API's: Specifically OpenSSL.

I have an algorithm that uses the following OpenSSL calls: HMAC_update() / HMAC_final() // ripe160 EVP_CipherUpdate() / EVP_CipherFinal() // cbc_blowfish These algorithm take a unsigned char * into the "plain text". My input data is comes from a C++ std::string::c_str() which originate from a protocol buffer object as a encoded UTF-8 ...

C++ Beginner - Trouble using classes inside of classes

Hello, I am working on a college project, where I have to implement a simple Scrabble game. I have a player class (containing a Score and the player's hand, in the form of a std::string, and a score class (containing a name and numeric (int) score). One of Player's member-functions is Score getScore(), which returns a Score object for...

Get gprof to profile based on wall-clock time?

My understanding is that by default gprof takes into account CPU time. Is there a way to get it to profile based on wall-clock time? My program does a lot of disk i/o, so the CPU time it uses only represents a fraction of the actual execution time. I need to know which portions of the disk i/o take up the most time. ...

Convert .o file to .exe

Is it possible to convert an object file .o that was created from a .c source code to .exe? And if it is possible is there a direct command using gcc? ...

printf("... %c ...",'\0') and family - what will happen?

How will various functions that take printf format string behave upon encountering the %c format given value of \0/NULL? How should they behave? Is it safe? Is it defined? Is it compiler-specific? e.g. sprintf() - will it crop the result string at the NULL? What length will it return? Will printf() output the whole format string or ju...

QLineEdit - focus event

Hi guys, I have to connect focus event from some QLineEdit element (ui->lineEdit) to the method focus(). How can I do this? ...

How do I retrieve program output in Python?

I'm not a Perl user, but from this question deduced that it's exceedingly easy to retrieve the standard output of a program executed through a Perl script using something akin to: $version = `java -version`; How would I go about getting the same end result in Python? Does the above line retrieve standard error (equivalent to C++ s...

How do I create a C++ console/terminal project in XCode?

I am using MacBook Pro Mac OS 10.5 with related version of XCode. I am new to this development environment. I want to develop C++ code for a console/terminal-based application using XCode on Mac OS 10.5, but I did not figure out how to create such type of project using XCode. Could anyone briefly describe the steps or refer me to some re...

linked list problem (with insert)

The problem appears with the insert function that I wrote. 3 conditions must work, I tested b/w 1 and 2, b/w 2 and 3 and as last element, they worked. EDIT; It was my own problem. I did not realize I put MAXINPUT = 3 (instead of 4). I do appreciate all the efforts to help me becoming a better programmer, using more advance and more ...

How do I increase the stack size for executables built with scons on Solaris?

Hi there, I am working with scons and am trying to compile a program that require bigger stack size but I dont know how to extend the stack size. This is on a solaris machine, and we use scons to compile our projects. Anyone know how to do this ? ...

Having issues with initializing character array

Ok, this is for homework about hashtables, but this is the simple stuff I thought I was able to do from earlier classes, and I'm tearing my hair out. The professor is not being responsive enough, so I thought I'd try here. We have a hashtable of stock objects.The stock objects are created like so: stock("IBM", "International Business M...