c++

How do I initialize a const std::pair ?

Let's say that I've got a : #include <utility> using namespace std; typedef pair<int, int> my_pair; how do I initialize a const my_pair ? ...

Check if a char* buffer contains UTF8 characters?

In the absence of a BOM is there a quick and dirty way in which I can check if a char* buffer contains UTF8 characters? ...

how to use ssl with smtp in c++

Hello all im looking for code example or tutorial on what i need to do to code sending email via email client ( that i already have ) that will support ssl authentication i guess using open ssl ...

Learning C++ without an IDE

I've recently started to learn C++ and am completely confused with the choices of IDEs and compilers out there. I am competent with interpreted languages and like the simplicity of using any IDE or text editor and then running the interpreter from the command line. Everything works as I expect, regardless of the IDE used, because I use t...

Unlock a thread from another process, in c++.

I'm programming an interprocess communication module (Process A and Process B). Is there any way the communication thread in B can run (be unlock) as soon as process A finishes a specific action, I mean without B doing any polling nor B waiting too much after A finishes its action? Which are the concepts/models/design patterns governin...

Initializing aggregate unions

I've got a union : union my_union { short int Int16; float Float; }; I'd like to create : const my_union u1 = ???; const my_union u2 = ???; and initialize their values to be of different types respectively : u1 -> int16 u2 -> float How do I do that ? If the above is not possible, are there any workarounds? ...

Heap randomization in Windows

Windows 7 has Heap randomization and Stack randomization features. How could I manage it? How they are affects performance of my application? Where I could find more information on how it works? I'm using Visual Studio 2008 for developing C++ programs. I can't find any compiler's options for that features. ...

OO Programming Design question: Global Object part II

Hi Sorry for reposting this, but for some reason I can not add comments to my older post. Some people wanted to know the exact error message I get when trying to do the following: I have probably a quite simple problem but I did not find a proper design decision yet. Basically, I have 4 different inherited classes and each of those cla...

How to put 2 increment statements in c++ for loop?

I would like to increment 2 variables in a for-loop condition instead of one. So something like: for(int i = 0, i != 5; ++i and ++j) do_something(i,j); What is the syntax for this? ...

Memory leak in C,C++; forgot to do free,delete

Hi All, We allocate memory in C using malloc and in C++ using new. I know that memory allocated must be freed or given back to OS using free in C and delete in C++. If I forgot to use free/delete after allocating memory, it means there will be memory leak. Now, my question is, is this memory leak only during the time period of executio...

How to take output from .NET executable and convey to MFC application ?

I have a dialog based MFC application through which I have to call a .NET executable. My question are: How will the MFC application know that the .NET executable is closed? if suppose a .Net executable process some information and want to convey the output to the MFC application, how can this be achieved. Please help!! ...

std::map::find(char*) not working on 64bit Machine in Debug Mode

Hi Guys, I am facing an interesting situation and want to share with all. Definitely, if some one can help I shall be grateful! #include "stdafx.h" #include <map> #define DEF_NAME1 "NAME1" #define DEF_NAME2 "NAME2" #define DEF_NAME3 "NAME3" #define DEF_NAME4 "NAME4" struct TInfo { const char * TName; const char * ...

Register a C# COM component?

I have developed a C# com component which I am using from managed c++. On my dev machine when everything works fine. However when I distribute the files, I received an error that the component has not been registered. When I try a regsvr32 on the dll it gives me an error (C# dlls cannot be registered). How do I properly register this COM...

How can I make a file selector with a combobox in VC++ 2008?

Hi, I have this dialog: ID__BATERIA __FAX DIALOGEX 0, 0, 235, 86 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Nueva batería de fax" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN DEFPUSHBUTTON "OK",IDOK,120,65,50,14 PUSHBUTTON "Cancel",IDCANCEL,175,65,50,14 LTEXT ...

syntax error: _stdcall -- Help? Please?

Hello, I am trying to use this code to define the APIs that are needed to communicate with a card reader. Below is the header file (complete). [AtUsbHid.h] It is throwing several errors, but I figure if the syntax issue is solved, the rest will fall into place. Please help me out. I made sure that __export was replaced with __declsp...

C++: simple passing char* ?

I want to simply pass a char as an argument to a function which should then be modified by the function. Unfortuantely, when doing it like below the printouts of the buffers are NOT equal. I do not understand as I pass a pointer to the char array. Anyone sees the obvious thing that is missing? unsigned char* buffer; doSomething(buffer) ...

Need of PRBS Pattern Generating C/C++ API

Hi, I am looking for PRBS Pattern Generating C/C++ API, So that i can insert it in Payload of UDP. If anybody know the procedure for generating PRBS pattern it would be greatfull. ...

Are there good Patterns/Idioms for Data Translation/Transformation?

Hi, I'm sorry for the generic title of this question but I wish I was able to articulate it less generically. :-} I'd like to write a piece of software (in this case, using C++) which translates a stream of input tokens into a stream of output tokens. There are just five input tokens (lets call them 0, 1, 2, 3, 4) and each of them can ...

Reading data from file into array of structs C++

I have a sample txt file and want to read the contents of the file into an array of structs. My persons.txt file contains 5 arbitrary nos one on each line. 7 6 4 3 2 My program looks like this: #include <iostream> #include <fstream> using namespace std; struct PersonId { typedef PersonId* ptr; PersonId(); int fId; }; ...

Why should I setup a plugin interface in c++ instead of c

As a result of my previous questions I asked myself: Is it usefull at all to setup a C++ interface for a plugin system? The following points are speaking against it: No common ABI between different compilers and their versions, no common layout of the objects in memory No direct class export. You have to export factories and destructor...