c++

Convert Between Floating Point Standards

I am trying to convert an IEEE based floating point number to a MIL-STD 1750A floating point number. I have attached the specification for both: I understand how to decompose the floating point 12.375 in IEEE format as per the example on wikipedia. However, I'm not sure if my interpretation of the MIL-STD is correct. 12.375 = (12)b...

How to read a input file with both argv and redirection from a input file

Hi experts, My program needs to accept three kinds of input commands below: ./Myprogram input.txt ./Myprogram < input.txt ./Myprogram I'm thinking about using argc to check the number of arguments to resolve the first two situations (since redirection doesn't count as an argument). But then I stuck on the last case, which simply wait...

C++ program crashes

I've this assignment to implement strcmp function. Sometimes it runs okay but other times it crashes. Please help me. #include <iostream> using namespace std; int mystrcmp(const char *s1, const char *s2); int main() { cout<<mystrcmp("A","A")<<endl; cout<<mystrcmp("B","A")<<endl; cout<<mystrcmp("A","B")<<endl; cout...

Algorithm to generate security token for MMO Login Service

I'm building a Login Service for an open source MMO game. I do not know much on the side of security/encryption and I am looking for a solution that will provide good protection against hackers and must not be too costly to generate. Our old system used a very simple system of authentication by storing the password as SHA1 in the databa...

How to compile/include unrarsrc in an objective-c project?

I'm trying to replicate the unrar functionality in this project: http://github.com/tarasis/QuietUnrar But having trouble. I have copied the relevant files (/libunrar/,QuietUnrarAppDelegate.) into my project so I can turn QuietUnrarAppDelegate into a more generalised Unrar class, and immediately I run into problems. All the source files...

How do I set a pointer to Null at run-time (C++)

Right now I have a pointer set to a row in my 2D array. I want that pointer to stop pointing to that row, but I will be using the pointer later for something else. I just want to know how to unset the pointer after it is initialized and has pointed to a row. double* tempRow; tempRow = (double*) malloc(size * sizeof(double)); ... te...

How would you implement attribute lists?

When speaking about attribute lists I mean a generic list which stores additional information for a class. The simplest case: A class has a std::map<std::string, std::string>. The first string names the attribute (like "Color"), the second string describes the value (like "Yellow"). In this example another class which uses these attribu...

How to draw triangler by using GraphicsView's QGraphicsItem class.

Hi guys i want to draw triangler object in graphicsview by using qgraphicsitem. But I dont know how to implement bounding rect according to triangler. ...

Why does my C++ object loses its VPTr

Hi Guys, While debugging one of the program's core dump I came across the scenario where its contained object which is polymorphic loses its VPTr and I can see its pointing to NULL. What could be the scenario when an object loses its VPTr. Thanks in advance, Brijesh ...

Read python dictionary using c++

Hi I have a python dictionary stored in a file which I need to access from a c++ program. What is the best way of doing this? Thanks ...

Can I create a map with a dynamic constructed comparer?

I want to create std::map in STL, but the comparer depends some dynamic value which is available only at runtime.. How can I make this? For example, I want something looks like std::map<int, int, Comp(value1, value2)>. value1 and value2 are not the compared number here, they are some kind of configuration numbers. ...

Sending messages to a thread?

I need to imlement in cocoa, a design that relies on multiple threads. I started at the CoreFoundation level - I created a CFMessagePort and attached it to the CFRunLoop, but it was very inconvenient as (unlike on other platforms) it needs to have a (systemwide) unique name, and CFMessagePortSendRequest does not process callbacks back t...

C++ XML library for use under Windows

Under Windows to parse XML one can use the COM based XML API but I wondered if there is any C++ XML libraries out there I can use for this purpose, without needing to get into the intricacies of COM? ...

lower_bound in set (C++)

Hi I've got a set and I want to find the largest number not greater than x in it. (something like lower_bound(x) ) how should i do it? Is there any predefined functions? set<int> myset; myset.insert(blahblahblah); int y; //I want y to be greatest number in myset not greater than x ...

SetLayeredWindowAttributes not working on Windows 7

I am using SetLayeredWindowAttributer to make a particular color of layered window transparent. This works fine on Windows XP,VISTA . But when I use the same on Windows 7 its not working. SetLayeredWindowAttributes(hWnd, RGB(0xff,0xff,0xff), 0, LWA_COLORKEY); When I use LWA_ALPHA then also it works. Problem is that I am not able to...

when to use const and const reference in function args

When writing a C++ function which has args that are being passed to it, from my understanding const should always be used if you can guarantuee that the object will not be changed or a const pointer if the pointer won't be changed. When else is this practice advised? When would you use a const reference and what are the advantages over...

COM Interoperability with .Net - missing methods/properties

I have a .Net asm with several interfaces and classes exposed to COM using the [ComVisible(true)] attribute. I generate a tlb, then reference this in my StdAdx file within a C++ COM component. What's odd is that for some reason, even though the very basic intellisense (VS6 for C++) is able to see my properties and methods, I get compil...

How to fetch memory in realtime after CreateProcess?

I have executed a process using CreateProcess, but I want to fetch or dump the memory area allocated to the process, preferably in real time. Unfortunately I do not know how to recieve the pointer to the memory are after creating the process. I've been searching around, but I have not found any useful answers so far. If anyone could hel...

Member-function pointers and phantom classes

I've been messing about with member-function pointers in relation to a previous question. In the code below I call methods on a class (B) that change a variable (count) in it, but I never make an instance of this class. Why does this work? #include <iostream> #include <string> #include <map> class A; typedef int (A::*MEMFUNC)(int, int)...

QT and Visual Studio 2010

Can any one provide me step by step how to get QT to work in VS2010? i have Visual Studio 2010 Ultimate Windows 7 Enterprise. qt-sdk-win-opensource-2010.05 qt-vs-addin-1.1.7 i tried executing this from vs command prompt : configure.exe -platform win32-msvc2008 -no-webkit -no-phonon -no-phonon-backend -no-script -no-scripttools -no...