Padding stl strings in C++
I'm using std::string and need to left pad them to a given width. What is the recommended way to do this in C++? Sample input: 123 pad to 10 characters. Sample output: 123 (7 spaces, prior to 123) ...
I'm using std::string and need to left pad them to a given width. What is the recommended way to do this in C++? Sample input: 123 pad to 10 characters. Sample output: 123 (7 spaces, prior to 123) ...
I wrote this really nice app that works just fine in Linux. It uses strptime(). Windows doesn't have this. Is there a Windows alternative for this? My coworker needs to use this app. (I tried googling it already to no avail) ...
Greeting Everyone I'm trying to compile and run a multi-language code in C, C++ and fortran using gcc, g++ & f77 respectively in UNIX. My program consists of two parts, one in C, the other in C++. They interface via a main() writen in C+, while the fortran code can be ignored for this case. I have been having numerous issues with this,...
Given: I fill up an array of handles with auto reset events and pass it off to WaitForMultipleObjects with bWaitAll = FALSE. From MSDN: “When bWaitAll is FALSE, this function checks the handles in the array in order starting with index 0, until one of the objects is signaled. If multiple objects become signaled, the function returns t...
Hello, I was reading C++ Faq Second Edition , faq number 32.08 . FAQ says that parameter passed by const reference and returned by const reference can cause dangling reference. But it is ok if parameter is passed by reference and returned by reference. I got it that it is unsafe in case of const reference but how is it safe in case ...
I have been programming for a few years now and have used function pointers in certain cases. What I would like to know is when is it appropriate or not to use them for performance reasons and I mean in the context of games, not business software. Function pointers are fast, John Carmack used them to the extent of abuse in the Quake and...
I am trying to make a program that records a whole bunch of things periodically. The specific reason is that if it bluescreens, a developer can go back and check a lot of the environment and see what was going on around that time. My problem, is their a way to cause a bluescreen? Maybe with a windowsAPI call (ZeroMemory maybe?). Anywho...
Hi, I am trying to implement the Winding Number Algorithm to test if a point is within another polygon. Although the results from my algorithm are wrong and not consistent. I have been working on this for ages now and it has become a bit of a pain! I have basically converted pseudo code from notes and websites, such as, softsurfer.com...
Having at least one virtual method in a C++ class (or any of its parent classes) means that the class will have a virtual table, and every instance will have a virtual pointer. So the memory cost is quite clear. The most important is the memory cost on the instances (especially if the instances are small, for example if they are just m...
Greetings Everyone, Trying to compile using g++ and need to link the standard f90 (or f77 even) libraries for some fortran source codes in my Makefile. I cant find the name of it anywhere. Makerfile: products: SlowDynamic.exe SlowDynamic.exe: main.o SA.o mersenne.o CFE.o BCs.o EMatrix.o Numbering.o KMatrix.o Solve.o MA_57.o blas.o MA...
I seem to recall reading about a way to 'reduce' the size of template spew in compiler errors associated with the boost libraries. My recollection is that it gives the template parameters nicer names than the compiler default naming (which is quite horrid). Is this real, or did I dream about it? I've been trying to find where I read thi...
Is there a way to tell the compiler (g++ in my case) to not optimize certain code away, even if that code is not reachable? I just want those symbols in the object file. Example: Here is a simple function, and I do want this function to be compiled, even if it's never called. void foo(){ Foo<int> v; } If there is no official compil...
I have an OpenGL program that works on all of my computers but one. It's a desktop with Vista 64 and a Radeon HD4850. The problem seems to be in my call to SwapBuffers(hdc). It compiles fine and then gives me an exception: Unhandled exception at 0x00000000 in Program.exe: 0xC0000005: Acces violation. Using VC++ to break before the cal...
I have a fairly complex Xcode project and I want to add Qt to it. I know that I can create a new project using qmake -spec macx-xcode project.pro but I don't want to have to hand configure my old project over the auto generated Qt project. Is there another option? [edited in a more general question below] It seems like it would be easi...
I want to implement a logical operation that works as efficient as possible. I need this truth table: p q p → q T T T T F F F T T F F T This, according to wikipedia is called "logical implication" I've been long trying to figure out how to make this with bitwise operations in C without using cond...
I've lost the C++ source code, but I keep the OBJ file. Are there any good C++ decompilers out there? ...
I have come across what seems like a really annoying bug running my C++ program under Microsoft Visual C++ 2003, but it could just be something I'm doing wrong so thought I'd throw it out here and see if anybody has any ideas. I have a hierarchy of classes like this (exactly as is - e.g. there is no multiple inheritance in the real code...
Note: Pass BSTR variable to COM method, HRESULT return is 8000FFFF Previous calls with interface pointer, was successful: HRESULT is 0 Execution, inside Visual Studio succeeds, outside fails - release and debug Illustration: const char *simFile; simFile = new char; //omitted _bstr_t simFileToOpen(simFile); BSTR raw_sim_Open = simFil...
Revised from previous question Note: Pass BSTR variable to COM method, HRESULT return is 8000FFFF Previous calls with interface pointer, was successful: HRESULT is 0 Execution, inside Visual Studio succeeds, outside fails - release and debug Illustration: BSTR raw_sim_Open = SysAllocString (L"c:\\example.S8"); hresult = pis8->raw_...
Hello, i need to get the mem usage VIRT and RES at run time of my program and display them. What i tried so far: getrusage (http://linux.die.net/man/2/getrusage) int who = RUSAGE_SELF; struct rusage usage; int ret; ret=getrusage(who,&usage); cout<<usage.ru_maxrss; but i always get 0. ...