c++

Interview Programming Questions - In house Exam

I have a company that would like to bring me in to serve me an hour long exam. No resources other than a pencil and paper. I really couldn't get any sort of feedback on the type of exam (implementation or generic) beside that it would test a few specific areas. Have you done anything like this? What sort of questions did they ask? What...

Thread safe lazy contruction of a singleton in C++

Is there a way to implement a singleton object in C++ that is: Lazily constructed in a thread safe manner (two threads might simultaneously be the first user of the singleton - it should still only be constructed once). Doesn't rely on static variables being constructed beforehand (so the singleton object is itself safe to use during t...

Alpha blending sprites in Nintendo DS Homebrew

I'm trying to alpha blend sprites and backgrounds with devkitPro (including libnds, libarm, etc). Does anyone know how to do this? ...

How do I make a GUI?

I've made many different seperate parts of a GUI system for the Nintendo DS, like buttons and textboxes and select boxes, but I need a way of containing these classes in one Gui class, so that I can draw everything to the screen all at once, and check all the buttons at once to check if any are being pressed. My question is what is the b...

Of Memory Management, Heap Corruption, and C++

So, I need some help. I am working on a project in C++. However, I think I have somehow managed to corrupt my heap. This is based off the fact that I added a std::string to a class and assigning it a value from another std::string: std::string hello = "Hello, world.\n"; /* exampleString = "Hello, world.\n" would work fine. */ exampleStr...

Windows C++: How can I redirect stderr for calls to fprintf?

I am wrapping existing C++ code from a BSD project in our own custom wrapper and I want to integrate it to our code with as few changes as possible. This code uses fprintf to print to stderr in order to log / report errors. I want to redirect this to an alternative place within the same process. On unix I have done this with a socketp...

How do you open a file in C++?

I want to open a file for reading, the C++ way. I need to be able to do it for text files, which would involve some sort of read line function, and a way to do it for binary files, which would provide a way to read raw data into a char* buffer. ...

I can't get my debugger to stop breaking on first-chance exceptions

I'm using Visual C++ 2003 to debug a program remotely via TCP/IP. I had set the Win32 exception c00000005, "Access violation," to break into the debugger when thrown. Then, I set it back to "Use parent setting." The setting for the parent, Win32 Exceptions, is to continue when the exception is thrown. Now, when I debug the program, it ...

MSVC6: Breakpoint stops program - WTF?

Using Microsoft Visual Studio 98, Microsoft Visual C++ 6.0 SP6 When running under the debugger, there's only one problem. If I pause the program and resume, everything's fine. The problem? When I hit a breakpoint, my program stops. But not in a good way; execution halts, I'm thrown out of debug mode into edit mode. All's fine until...

Secure Memory Allocator in C++

I want to create an allocator which provides memory with the following attributes: cannot be paged to disk. is incredibly hard to access through an attached debugger The idea is that this will contain sensitive information (like licence information) which should be inaccessible to the user. I have done the usual research online a...

Should I move from C++ to Python? ... Or another language?

In the company I work for, we do a lot of file-based transaction processing. The processing centers around the conversion of files between numerous formats to suit numerous systems in numerous companies. The processing almost always involves an XML stage and can include a lot of text parsing, database lookups, data conversion and data v...

Memcached on Windows (x64)

Does anyone know IF, WHEN or HOW I can get Memcached running on a Windows 64bit environment? I'm setting up a new hosting solution and would much prefer to run a 64bit OS, and since it's an ASP.Net MVC solution with SQL Server DB, the OS is either going to be Windows Server 2003 or (hopfully!) 2008. I know that this could spill over i...

How do you create a static class in C++?

How do you create a static class in C++? I should be able to do something like: cout << "bit 5 is " << BitParser::getBitAt(buffer, 5) << endl; Assuming I created the BitParser class. What would the BitParser class definition look like? ...

How do you pass a function as a parameter in C?

I want to create a function that performs a function passed by parameter on a set of data. How do you pass a function as a parameter in C? ...

any good tool for makefile generation?

Hi. I'm looking for a tool which can generate makefile for a C/C++ project for different compilers (gcc, microsoft vc++, borland etc) and different platforms (Win, Linux, Mac). ...

Playing wave file ends immediatly (C++, Windows)

I've got a following situation. On a machine there is a Fritz ISDN card. There is a process that is responsible for playing a certain wave file on this device's wave out (ISDN connection is made at startup and made persistent). The scenario is easy, whenever needed the process calls waveOutWrite() on the previously opened wave device (ev...

Validating a Win32 Window Handle

Given a handle of type HWND is it possible to confirm that the handle represents a real window? ...

Generic iterator

I am trying to find a generic way of accessing a set of containers. I have a standard vector and list in addition to another custom list. The custom list defines an iterator; class Iterator: public std::iterator<std::forward_iterator_tag, T> { // ... } Iterator begin() { return (Iterator(root)); } Iterator end() { return ...

Removing icon from Windows title bars without ditching close button or system menu?

Hi! I'm developing an MFC application and I've recently been searching for a good method to remove the icon from a Windows title bar, but retain the close button. The two obvious candidate solutions are turning off the system menu style or using the tool window style, but I would prefer not to disable the system menu or use the shrunken ...

Any good advice on using emacs for C++ project?

Hi. I'm looking for a good article on using emacs as C/C++ IDE. Something like Steve Yegge's "Effective emacs". ...