c++

can someone break this line apart gcc -E -dM - </dev/null

Just came across this guy that left me stunned: gcc -E -dM - </dev/null This part is confusing to me: - </dev/null ...

String comparisons. How can you compare string with std::wstring? WRT strcmp

I am trying to compare two formats that I expected would be somewhat compatible, since they are both generally strings. I have tried to perform strcmp with a string and std::wstring, and as I'm sure C++ gurus know, this will simply not compile. Is it possible to compare these two types? Is there an easy conversion here? ...

Invalid Algorithm Specified CryptoAPI

I am trying to decrypt something using 128BIT AES Decryption. When i attempt to calling CryptDecrypt i get an Error stating "Invalid Algorithm Specified". I get the same problem when using the library posted here: http://www.codeproject.com/KB/security/WinAES.aspx What can cause this error? I am using CryptoAPI along on vista64bit with...

Illegal Argument Execv() Unix C++

So I basically have a vector args with 1 argument per array that I'm trying to pass to an execv() call in unix. Execv accepts two parameters like so: int execv(const char *path, char *const argv[]); What's the best way to convert my vector of strings to an array of pointers ? Right now I'm doing the following but when I run it with s...

VC++ win32 API programming :how can i get the image out of the clipboard and display it in a winodws?

hi there ,i m new here . stackoverflow is a good place to help others and being helped. so i post my problem here.i'va asked quite a few people and find no answers. thanks Use SelectObject() on your memory DC to select the bitmap into it.This makes me puzzled. i read the msdn but still don't konw how to fill the second parameter of Se...

C++: Does return statement copy values

I am wondering about this because of scope issues. For example, consider the code typedef struct { int x1;/*top*/ int x2;/*bottom*/ int id; } subline_t; subline_t subline(int x1, int x2, int id) { subline_t t = { x1, x2, id }; return t; } int main(){ subline_t line = subline(0,0,0); //is line garbage or isn't...

Should I learn recursion before OOP?

I am reading this C++ book, "Problem Solving with C++" in my free time. I have gotten through 4 chapters, and now I am at a split. I can either go to chapter 5 which is file operations and an introduction to OOP, or I can go to chapter 12 which is recursion. So far I have only gone over compiler basics, all that if, else, and loops synta...

How do you program safely outside of a managed code environment?

If you are someone who programs in C or C++, without the managed-language benefits of memory management, type checking or buffer overrun protection, using pointer arithmetic, how do you make sure that your programs are safe? Do you use a lot of unit tests, or are you just a cautious coder? Do you have other methods? ...

Variable parameter lists in C++ and C

I'm working on rewriting a C program in C++ to take advantage of OO aspects so it can easily support multiple devices, and one part of the program is an expression evaluator. Expressions can have function calls, and here's the structure for functions. typedef struct { char *name; int argc; void (*func) (); } FUNCTION; Some...

Explicit Linking DLL and Program Hangs

Hello, I've the following piece of code in my program which dynamically links wtsapi32.dll file for session notifications like WTS_SESSION_LOCK and WTS_SESSION_UNLOCK and runs in background. After the first lock/unlock the program hangs and not responding. Is this a right way of doing explicit linking ? void RegisterSession(HWND...

Monitor the data in a table

How to write a shell script/process which runs like a daemon on Unix and continuously monitors a field in the table and sleeps for 30 sec's. The field value will regularly increase to a maximum value and my process/script which is monitoring will provide a simple select query output to a log file. any approach is preferred. ...

Autocompletion with qcompleter for fragments in the middle of a word

Is there an example available of a QCompleter subclass that will provide autocompletions for fragments that appear in the middle of words? eg: Suppose you have the wordlist { "apple", "pear", "banana" }. When the user types 'p', the suggested autocompletions should be apple and pear, but not banana (because apple and pear both contai...

I heard that Python has automated "garbage collection" , but C++ does not. What does that mean?

I heard that Python has automated "garbage collection" , but C++ does not. What does that mean? ...

Why/how does this compile?

C++ in MS Visual Studio 2008. Warning level 4 plus a load of extra warnings enabled as well. I'd expect this to give a warning at least, but more likely a compiler error? Function declaration is as follows: int printfLikeFunction( const int bufferLength, char * const buffer, const char * const for...

C++ returning queue pointer from function error

I have a function queue< pair<int,int> > * factorize(int n) { ...} It shows this compile error. generatePrimes.cpp:20: error: expected constructor, destructor, or type conversion before '<' token generatePrimes.cpp:20: error: expected `,' or `;' before '<' token What's wrong? ...

How can I code this problem? (C++)

I am writing a simple game which stores datasets in a 2D grid (like a chess board). Each cell in the grid may contain a single integer (0 means the cell is empty). If the cell contains a number > 0, it is said to be "filled". The set of "filled" cells on the grid is known as a "configuration". My problems is being able to "recognize" a ...

How to call a dll with "_pascal calling convention" from Delphi ?

I have a dll RL6_dll.dll from a routing program RouteLogix that is used to plan trucks etc. Now we want to use that from Delphi 2007. We have a c++ header for the dll and a working example that use it in C++-Builder. Here is an example from that file: // Use this routine to find the directory where the data-xxx subdirectories // are e...

Set location of MessageBox?

I want to print out a message using MessageBox (or similar). I would also like control over where exactly on the screen the box appears but can find nothing in the description of MessageBox that allows you control over the location. Did I miss something? If MessageBox can not be used, then is there an alternative? For reasons too comple...

C++ specialization, type_of or just typeid

Hello, I would like to know what is better to use in my situation and why. First of all I heard that using RTTI (typeid) is bad. Anyone could explain why? If I know exactly types what is wrong to compare them in a runtime? Furthermore is there any example how to use boost::type_of? I have found none searching through the mighty google :...

Minimal project rebuild?

I'm using a 3rd party cross-platform project builder which utilizes various compilers. This project builder always rebuilds the project fully and I'm trying to implement a "smart-rebuild" machanism. I thought of running the preprocessor on each .cpp, crc the result and compare it against the CRC of the previous rebuild. If they differ, ...