c++

Restore the state of std::cout after manipulating it.

Hello Everyone, Suppose I have a code like this: void printHex(std::ostream& x){ x<<std::hex<<123; } .. int main(){ std::cout<<100; // prints 100 base 10 printHex(std::cout); //prints 123 in hex std::cout<<73; //problem! prints 73 in hex.. } My question is if there is any way to 'restore' the state of cout to its orig...

How to create a C-style array without calling default constructors?

I am writing a memory-managing template class in which I want to create a C-style array of fixed size, to serve as a heap. I keep the objects stored in an array like this: T v[SIZE]; As this only serves the role as a heap that can hold T objects, I don't want the T default constructor to get automatically called for every object in th...

VFD display programming

I have a VFD display from Soundgraph and I want to know if there are some current API (C#, JAVA, C++, C, etc.) to program it. ...

Magic COLORREF/RGB value to determine when to use light/dark text

Years ago, in my long lost copy of Charles Petzold's Windows 3.0 Programming book, there was a magic COLORREF or RGB value documented that you could use to check whether you should draw text in a light colour or a dark colour. E.g. if the background colour was below this value, then use black text, if it was higher, use white text. Doe...

Graphics primitive generators

I'm looking for something that can generate primitives (e.g. rounded rectangles for dialog boxes etc) so I can load them into a DirectX textured Sprite. Functionality is like SPriG. ...

Getting ordinal from function name programatically

Hey, Does anyone What's the easiest way in C++ to get an ordinal of an exported dll function, given its name? (Looking for a way which doesn't invlove parsing the IATs myself...) Thanks, Dan ...

Is <value optimized out> in gdb a problem?

I have an application that only crashes in -O2 optimization (compiled with gcc 4.2.4). When I step through the code and get to the spot that crashes and try to inspect the value, I get a "value optimized out" in gdb. I read on the internet that this means that the value is stored in the register. I was wondering if my crash could be r...

C++: returning by reference and copy constructors

References in C++ are baffling me. :) The basic idea is that I'm trying to return an object from a function. I'd like to do it without returning a pointer (because then I'd have to manually delete it), and without calling the copy-constructor, if possible (for efficiency, naturally added: and also because I wonder if I can't avoid writi...

How do I use Xerces w/ in a Windows environment?

I have downloaded the source for Xerces and am trying to use it in a Greenhills project. I get the following error: could not open source file "xercesc/util/Xerces_autoconf_config.hpp" The code where the error hit is commented as: // If the next line generates an error then you haven't run ./configure #include <xercesc/util/Xerces_...

Update system environment variable from c++

Hey folks, I am currently writing an unmanaged C++ program which works with a system environment variable. I am getting the value with GetEnvironmentVariable(...). Now I have an C# program which may change this variable at any time, e.g. like this: Environment.SetEnvironmentVariable("CalledPath", System.Windows.Forms.Application.Execut...

Simulating Java's Thread.sleep() in WM

Is there an easy way to make some "sleeping program" functionality by just calling function, such as it has been made in Java with Thread.sleep()? Sleep method causes, in brief, app to wait indicated time (no. of milisec.) and after that time returns to next line of code (so it "blocks" - it isn't not proper word, though - the current t...

OpenGL Calls Lock/Freeze

I am using some dell workstations(running WinXP Pro SP 2 & DeepFreeze) for development, but something was recenlty loaded onto these machines that prevents any opengl call(the call locks) from completing(and I know the code works as I have tested it on 'clean' machines, I also tested with simple opengl apps generated by dev-cpp, which wi...

Send custom information through Windows FileSystem Attributes

Before getting into the point, I'll give you an overview of what I want to do. Because I don't know if using Windows Filesystem attributes is the right option to do that. I have two components in the system. One of them is a ShellExtension that put an OverlayIcon when some condition is satisfied, and the other component is a Filesystem ...

fatal error LNK1104: cannot open file 'libboost_regex-vc90-mt-gd-1_42.lib'

i'm trying to use boost regex within my program the problem is i get this error... the only installation step i did was to add: "C:\Program Files\boost\boost_1_42" into the Additional Include Directories... i'm using VS2008... trying to implement this: #include <iostream> #include <string> #include <boost/regex.hpp> using namespace s...

partition and mbr recovery

how do you read mbr and partition table from the hard disk and edit it? I want to know exactly how do the partition recovery softwares work? ...

What are the default return values for operator< and operator[] in C++ (Visual Studio 6)?

I've inherited a large Visual Studio 6 C++ project that needs to be translated for VS2005. Some of the classes defined operator< and operator[], but don't specify return types in the declarations. VS6 allows this, but not VS2005. I am aware that the C standard specifies that the default return type for normal functions is int, and I ass...

QPixmap from QBitmap

I am converting a win32 api graphing library to use the qt library instead. I have managed to compile succesfully on XP, now to test true cross-platform capability of the new and improved graphing library, I am attempting to build it on Ubuntu (9.10). I have encountered a couple of compile time erros - because some of the classes are Wi...

How to determine how many bytes an integer needs?

I'm looking for the most efficient way to calculate the minimum number of bytes needed to store an integer without losing precision. e.g. int: 10 = 1 byte int: 257 = 2 bytes; int: 18446744073709551615 (UINT64_MAX) = 8 bytes; Thanks P.S. This is for a hash functions which will be called many millions of times Also the byte sizes do...

How to list exported functions in a shared lib on Ubuntu

I have just built a shared lib on Ubuntu, and when I attempt to use the function, the application that loads the library is reporting 'xxx' symbol not found. I want to check (i.e. list) the functions that are exported by my library so I can investigate this issue further. Relevant details: OS: Ubuntu 9.10 compiler: gcc 4.4.1 link...

Throwing non-const temporaries by reference

Is there any problem with throwing an object constructed on the stack in a try-block by non-const reference, catching it and modifying it, then throwing it by reference to another catch block? Below is a short example of what I'm refering to. struct EC { EC(string msg) { what = msg; } string where; string what; void ap...