c++

switch structures with structs and arrays?

I had an earlier question about organizing some inputs by name, ID, and then Amount. Now that I have figured out how to get them organized, I need to have 3 outputs; the first by name, the second by ID, and the last by amount. can i use case and switch statements? Every time i tried to, all three outputs were by name. this is what i hav...

Get the domain name of a computer from Windows API

Hi, In my application I need to know if the computer is the primary domain controller of a domain, so I need to know the domain of the computer to call NetGetDCName function. Thanks. EDIT: The problem is related with the DCOM authentication so I need to know the domain to use the DOMAIN\USERNAME in case of a PDC or COMPUTER\USERNAME ...

Is this a valid C++ function or not?

It seems to me that this function would not be valid since it uses the keyword 'default' as an identifier: int foo() { int default = 42; return default; } However, the Microsoft C++ compiler (versions 14.00.50727.762 and 15.00.30729.0) compile the code without warnings or errors (using the simplest possible command line: 'cl f...

Bipartite Matching

How can I implement a bipartite matching algorithm (probably based on a max-flow algorithm) in C or C++ ? To be specific, I have this input in a file: (1,3) (1,5) (2,5) (M,F) --> where M represents id of MALE and F is id of FEMALE. I need to find the maximum number of matches and show matched couples. Like: matches: 1&3 , 2&5 I h...

scrollbars in plugin code

I'm working on a plugin for Firefox on a mac. our plugin has it's own scrollbar. How does the event stucture differ for controlling a scrollbar within a plugin, vs in a normal application? Symptoms: code works fine in a stand alone application. Mouse wheel works fine in both cases. In plugin, the scrolling isn't live, and often won't a...

C++ Email/SMTP

Hey, Can you recommend me what C++ library or classes are available for sending email via SMTP in C++. I'm on Windows platform. I need a library which supports attachments and SSL connections. What are the options available. I'm not into implementing my own :) Regards EDIT: Oh I forgot to mention I'm using Visual C++ 6 ...

How can I remove the leading zeroes from an integer generated by a loop and store it as an array?

I have a for loop generating integers. For instance: for (int i=300; i>200; i--) {(somefunction)*i=n; cout<<n; } This produces an output on the screen like this: f=00000000000100023; I want to store the 100023 part of this number (i.e just ignore all the zeros before the non zero numbers start but then keeping the zer...

C++: Function wrapper that behaves just like the function itself

How can I write a wrapper that can wrap any function and can be called just like the function itself? The reason I need this: I want a Timer object that can wrap a function and behave just like the function itself, plus it logs the accumulated time of all its calls. The scenario would look like this: // a function whose runtime shoul...

How do I monitor the lock on a file to see when it is released? [C++]

Hello all, I am looking for a way to create a program in unmanaged c++ that waits until a file is unlocked (as in it is no longer in use) and than does something. I have had no luck locating how to do this, any help would be appreciated! UPDATE: I may have answered my own question, see below and tell me what you think.. UPDATE: All th...

What is the difference between a template class and a class template?

What is the difference between a template class and a class template? ...

how do i remove an element of an array and shift the reamining elements down

hi guys how do i remove an element of an array and shift the reamining elements down so if i have an array array[]={1,2,3,4,5} and want to delete 3 and shift the rest so i have array[]={1,2,4,5} how would i go abot this in the least amount of code! ...

is there a difference between a struct in c++ and a struct in c#?

is there a difference between a struct in c++ and a struct in c#? ...

C++: How to implement a timeout for an arbitrary function call?

I need to call a library function that sometimes won't terminate within a given time, unfortunately. Is there a way to call the function but abort it if it doesn't terminate within n seconds? I cannot modify the function, so I cannot put the abort condition into it directly. I have to add a timeout to the function externally. Is it may...

How to tell if stderr is directing output to a file?

Is there a way I can tell whether stderr is outputting to a file or the terminal within a C/C++ program? I need to output different error message depending on whether the program is invoked as: ./program or like: ./program 2>> file ...

How can I detect file accesses in Linux?

I have a bunch of flows and data processing applications that I occasionally need to spy on, meaning I need to know what files they read. This is mostly to aid in packaging testcases, but can also be useful when debugging. Is there a way to run the executables in such a way that produces such a list? I have two thoughts on this: Ther...

how do clean up deleted objects in C++

Is it possible to zero out the memory of deleted objects in C++? I want to do this to reproduce a coredump in unit test: //Some member variable of object-b is passed-by-pointer to object-a //When object-b is deleted, that member variable is also deleted //In my unit test code, I want to reproduce this //even if I explicitly call delete...

How to capture events fired from new Popup IE window

Hi, Greetings! Situation: My ActiveX DLL contains a customized webbrowser. The webbrowser displays a web page. When user clicks the link within the displayed page, a new IE window pop up and navigate to the clicked link URL. Question: How can I capture the DocumenComplete and NavigateComplete events fired from the NEW pop up IE win...

D8045: cannot compile C file 'serialcommands.c' with the /clr option

I am getting compiler error D8045. cannot compile C file 'serialcommands.c' with the /clr option. This file is a C library that has been written to talk over a serial port to a TI processor. The task that I need to do is wrap this library with a CLR wrapper (there will be additional questions posted to stackoverflow concerning marshall...

[C++] Problems with boost::ptr_vector and boost::any

Hey all, ok, so I got a doubt, I want to know if this is possible: I'm using a database, with generic data (strings, ints, bools, etc...). Whenever an object is constructed or a member of an object is modified, I have to query the database with the specific action (SELECT or UPDATE). First of all, this isn't a DB related question, my r...

C++ Interface Compiling

EDIT: I figured out the solution. I was not adding -combine to my compile instructions and that was generating the errors. I'm in the process of working through the Deitel and Deitel book C++ How to Program and have hit a problem with building and compiling a C++ interface using g++. The problem is, I've declared the class in the .h...