c++

Number of Items in a Column inside a grid

Hi, How do you find number of items in a column inside a grid? I have a grid (listview control to be specific), and have some items. Some times a given row might not be full. ANd can have values in fewer than maximum columns. I need to find Number of items in a given Column. If the grid is like 1 2 3 4 5 6 7 and if i...

Using sprintf will change the specified variable.

Hi, I have a code, char* bin2hexchar( const unsigned char& ibin, char* pbcd ) { sprintf( pbcd, "%02X", ibin ); return pbcd; } The problem is, the value of ibin variable will change to zero value. Please advice. Thanks ...

How do I make my Factory's Header not dependent on the templated objects it creates?

I have an abstract base class like so: class AbstractBaseClass {}; a templated concrete class that derives from it: template<class T> class ConcreteClass : public AbstractBaseClass { public: ConcreteClass(T input) : data(input) {} private: T data; }; AndI have a factory class that creates AbstractBaseClasses class MyFactor...

A design issue with a tree of information in C++.

Sorry in advance for the lengthy explanation! I have a C++ application that uses a hash_map to store a tree of information that was parsed from a text file. The values in the map are either a child hash_map or a string. These values were parsed from a text file and then stored into the map. I wanted to avoid having to send the strings ...

Widget display problem in QT?

Hi., i am trying to create layout like this (Please see the Picture) http://i225.photobucket.com/albums/dd200/saravanan_comp2001/layout.jpg In the QT i created widgets and put in the main widget, the problem is not visible. none of the widget's are not shown. please help me to fix this issue Complete Source Code sandbox.ifuturemec.c...

What is a good naming convention for vars, methods, etc in C++?

Hi all. I come from a the Objective-C and Cocoa world where there are lots of conventions and many people will say it makes your code beautiful! Now programming in C++ I cannot find a good document like this one for C++. http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CodingGuidelines/CodingGuidelines.html Stand...

how to get MAC aaddress and Modified date of text file in C++ builders

hi, how to get mac address of pc and modified date of text file in runtime program,using C++ builder,if both matches red color rectangle should come,or else green colour...as an output ...

C++ to C conversion

Hi, I have a working C++ source code but I need it to be in C. Can anybody tell me what conversions must be made in order to make it work in C. Please help me... TNX. I can email the source code if it would help... ...

share a same sql connection among multiple executables

I, I am looking for a way to share a sql connection between two (or more) C/C++ executables. By sql connection sharing, i mean to have a transactional context in common : the A module can start the transaction, the B module do some work, and the C can commit the transaction. Of course, if a module wants it, it can throw an exception a...

How to prevent a Linux program from running more than once?

What is the best way to prevent a Linux program/daemon from being executed more than once at a given time? ...

How do I convert this code to c++?

I have this code: string get_md5sum(unsigned char* md) { char buf[MD5_DIGEST_LENGTH + MD5_DIGEST_LENGTH]; char *bptr; bptr = buf; for(int i = 0; i < MD5_DIGEST_LENGTH; i++) { bptr += sprintf(bptr, "%02x", md[i]); } bptr += '\0'; string x(buf); return x; ...

How do I make a 3D game in my spare time?

I'm looking for a new project to fill the evenings and I wish to make a 3d game. I have mediocre experience in Pascal,and VB but realise that neither of these may be best for the job. I realize I may have to spend some time reading some books and maybe learning a new language but I don't actually know what would be needed? Would learnin...

.NET Compatibility Limitations

Acorrding to the document I just read, global Windows compatibility for .NET Framework 3.5 is 10%: link This is not good news for my project where the installer is built in .NET and my application is C++. What are ways to combat this problem without having to require users to install any additional framework manually? ...

COM - what does _pAtlModule->Lock() lock exactly?

Hi I'm working my way through learning writing a COM control. I've got an example project, and it uses the lines _pAtlModule->Lock() _pAtlModule->Unlock() in the OnCreate() handler and the OnDestroy() handler for the COM control respectively. I realise that the _pAtlModule is an instance of the CAtlModule - the "application" object ...

Spiral rule and 'declaration follows usage' for parsing C expressions

This question follows this other question about C declaration. Reading the answer to this question, I read about the spiral rule and I also understood what "declaration follows usage" means. Ok so far. But then I read this declaration: char *(*(*a[N])())(); and I was wondering how to parse it with the "declaration follows usage" 'ru...

Flexible application configuration in C++

Hi, I am developing a C++ application used to simulate a real world scenario. Based on this simulation our team is going to develop, test and evaluate different algorithms working within such a real world scenrio. We need the possibility to define several scenarios (they might differ in a few parameters, but a future scenario might als...

How to use ZwQueryInformationProcess to get ProcessImageFileName in a kernel driver

I'm writing a simple kernel driver for my application (which is somehow an antimalware application). I hooked ZwOpenFile() and got the process handle calling this API with PsGetCurrentProcess() which returns a PEPROCESS stucture: PEPROCESS proc = PsGetCurrentProcess(); then I used ZwQueryInformationProcess to get the PID and ImageFil...

why ostringstream could not work well in multithreading environment

Maybe something is weird. When I use STL ostringstream class in my multithreading environment I found that the execution time of each thread increased linearly as the thread number increased. I don't know why this happened. I try to check the ostringstream source code but could not find any synchronization code. Are there some synchroniz...

C++ Array of Objects

I have an array in a class that should hold some instances of other objects. The header file looks like this: class Document { private: long arraysize; long count; Row* rows; public: Document(); ~Document(); } Then in the constructor I initialize the array like this: this->rows = new Row[arraysize]; But for some...

How to implement std::set or std::hash_set to filter the duplicated item in an array list?

Given the below scenario, I'm having a list of item which might be having some duplicated item. I would like to filter the item, to print the only unique item. Instead of duplicating a list which remove the duplicated item, I tried to insert them into std::set and std::hash_set. Nevertheless, I found no useful example to perform the op...