c++

Parallel Processes In User Runtime Environment

I have a C++ program that allows a user to single step through processor instructions as a processor simulator emulates a MIPS processor. The problem is that, at least in my testing stages, I need to initialize ~2^32 integers to 0xDEADBEEF. I do this at start-up. It isn't extremely important that this happens completely before I start...

Array Division - What is the best way to divide two numbers stored in an array?

I have two arrays (dividend, divisor): dividend[] = {1,2,0,9,8,7,5,6,6}; divisor[] = {9,8}; I need the result (dividend/divisor) as: quotient[] = {1,2,3,4,5,6,7}; I did this using array subtraction: subtract divisor from dividend until dividend becomes 0 or less than divisor, each time incrementing quotient by 1, but it takes a...

Combination of types using boost::mpl

I have a list of types, from which I want to construct the list of all combinations with two elements. For example: namespace mpl = boost::mpl; typedef mpl::vector<int, long> typelist; // mpl magic... // the wanted list is equivalent to: typedef mpl::vector<pair<int, int>, pair<int, long>, pair<long, int>, pair<long,...

How to attach metadata to each frame of a video

I would like to be able to store metadata on each frame of a video file (a key to value map with ~10 entries per frame). Which video format allows me to store such data ? Where can I find a c++ library to do this ? Thank you very much for your answers. ...

Link Error With Visual Studio 2005 Using Windows SDK 7.1

I am in the process of evaluating an upgrade to Windows SDK 7.1 Part of my team's legacy codebase is a large number of ATL web services, which are still maintained using Visual Studio 2005 because (I am told) ATL web services are not supported in versions beyond 2005. When I pointed the IDE to SDK 7.1, I began to receive the following ...

fscanf multiple lines [c++]

I am reading in a file with multiple lines of data like this: :100093000202C4C0E0E57FB40005D0E0020C03B463 :1000A3000105D0E0022803B40205D0E0027C03027C :1000B30002E3C0E0E57FB40005D0E0020C0BB4011D I am reading in values byte by byte and storing them in an array. fscanf_s(in_file,"%c", &sc); // start code fscanf_s(in_file,"%...

Learning parsing with C++

I want to learn the basics of Parsing with C++. For that matter I thought of a simple Configuration Language that might look like this: /* same comment syntax as in C++ keywords: "section" = begins a new section block "var" = defines a new var ... */ section MySection { // also valid: section "MySe...

What are some areas of C++ code that could be affected by porting to Visual 2005 and changing to unicode?

We recently ported over legacy code to now use Visual Studio 2005 and unicode. What are the key areas that are affected by switching to the unicode character set? ...

C++ array value sorting

If I want to sort the second dimension's 0 element like that: short arr[5]; arr[0][0] = 122; arr[0][1] = 33; arr[0][2] = 45; arr[1][0] = 33; arr[1][1] = 12; arr[1][2] = 42; . . . It will sort arr[i][0], but arr[i][1] and arr[i][2] will come with arr[i][0] to a new element. ...

Multipe Send()'s and Recv()'s using Winsock2

Hello, I am working on a small networking project using Winsock2. I am using a TCP connection and actually am working with IRC as an example since IRC is fairly simple. What I am doing is connecting to the server and sending an initial buffer so the server recognizes a connection. This works fine. What concerns me is that I cannot writ...

BitBlt + UpdateLayeredWindow and CreateDIBSection in 16-bit desktop color depth

Hello there! I have an application with transparent background in client area which is drawn black because the window is not layered. In each of it's WM_PAINT messages I am doing a BitBlt to a memory-DC, after that I use the memory-DC with UpdateLayeredWindow to a layered canvas window. setup of memory-DC: HDC hdcMemory = CreateCompat...

Difficulty writing a Bmp file in C++ manually (using Xcode)

I'm currently trying to create a ray tracer in C++ but I'm having difficulty writing the .bmp produced at the end. I'm determined to do it manually, so I can learn more about image files and writing them etc. But I'm having some difficulty. I'm fairly new to C++ but have been using Python for a while. I'm almost there now, I just have...

Stream Operator Overloading

Why should overloading of stream operators(<<,>>) should be kept as friends rather than making them members of the class? ...

C++ vector copy elements?

I would like to use a dynamic array in C++ (something like an ArrayList or a Vector in Java.) In this example are the t1, t2... objects are copied or only its address is added to the vector? Do I need to implement a copy constructor for Node class or will the default constructor make a "proper" copy (because there is a pointer in the cla...

How to track Finger tip in OpenCV or OpenFrameworks ?

I want to develop a program which uses the webcam to track finger tips. When tracked, the finger tip will be like an index and I will be able to get its positions even if it is moved around. If anyone has any advice for me. Thanks in advance. ...

C++ Replacing system("pause") call

I've read that system("pause") is slow and not advisable to use. Is there any function that I can use instead of that? I've tried getchar() but if I have a scanf call before, it simply does not waits for an other input, only if I put an other getchar() under it (but I don't think it's a good solution). edit: I'm using Microsoft Visual S...

What do linkers do?

I've always wondered. I know that compilers convert the code you write into binaries but what do linkers do? They've always been a mystery to me. I roughly understand what 'linking' is. It is when references to libraries and frameworks are added to the binary. I don't understand anything beyond that. For me it "just works". I also unde...

C++ variable scope error inside for loop

//Constructing set of all Places in Conflict with each other int l_placeVec, l_placeVec1,p; for(SP_ListListNode::const_iterator iter = m_postTransitionsSet.begin(),l_placeVec=0; iter != m_postTransitionsSet.end(); iter++,l_placeVec++) { for(SP_ListListNode::const_iterator inneriter = m_postTransitionsSet.begin(),l_placeVec1=0; inneri...

ANTLR3 C Target with C++ Exceptions

I have some experience with ANTLR 2's C++ target, but have been hesitant to spend much time on ANTLR 3 because of my fears about exception safety. Sadly, ANTLR 3 only has a C target which produces C which is "C++ compatible." This does not seem to include C++ exception safety, based on the following: You can probably use [exception...

Way for C++ destructor to skip work when specific exception being thrown?

I have an object on the stack for which I wish its destructor to skip some work when the destructor is being called because the stack is being unwound due to a specific exception being thrown through the scope of the object on the stack. Now I could add a try catch block inside the scope of the stack item and catch the exception in ques...