Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win







C++ is an intermediate-level general-purpose programming language, not to be confused with C or C#. It was developed as a set of extensions to the C programming language to improve type-safety and add support for automatic resource management, object-orientation, generic programming, and exception handling, among other features.

Share tech news, updates, or what's on your mind.

Sign up to Post

I use : to create  a new HWND

But requires the strike code for the window HWND chance his size

bool HWND (chance size)
x = windowX
y= windowY


BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
   HWND hWnd;

   hInst = hInstance; // Store instance handle in our global variable

   hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,

   if (!hWnd)
      return FALSE;

   ShowWindow(hWnd, nCmdShow);

   return TRUE;

Open in new window

i use,
hwndEdit = CreateWindowExW(WS_EX_CLIENTEDGE, TEXT("Edit"), NULL, WS_CHILD, 10, 10, 200, 150, hWnd, (HMENU) NULL,NULL,NULL );
ShowWindow(hwndEdit, SW_SHOW);

Open in new window

to add a text box of one line , now i want to add a multi line field.

after solving some ugly other problems with make, I run now into the problem about the CXXFLAGS. It looks like make do not use this FLAGS.  My makefile looks like:

CXX = g++
CXXFLAGS = -g -std=c++11 -Wall -pedantic

root := /usr/share/doc/xsd/examples

include $(root)/build/cxx/rules.make
include $(root)/build/xsd/tree-rules.make

$(CXX) $(CXXFLAGS) -c 05_bxf2.cxx

	$(CXX) $(CXXFLAGS) -c XSDValidator.cpp

	$(CXX) $(LDFLAGS) -o XSDValidator.o 05_bxf2.o

	rm -f *.o

Open in new window

The repsone I got in termional after calling make

g++ -W -Wall -O3 -c 05_bxf2.cxx

Open in new window

This is not what I added to the makefile. Any idea why make do not use the Flags?

When i, wane add a new EDIT child window which the user can type text from the keyboard.
a normal text box works, but when I challenge  CreateWindowExW( EDIT ..)

and  BUILD and run the program from my compute noting happens.

Do i miss the paint code or something.

//  Add a new TEXT imput box
//CreateWindow(TEXT("EDIT"),TEXT ("VALEU"), WS_VISIBLE | WS_CHILD | WS_BORDER ,10,10 ,200,25,hWnd, (HMENU) NULL,NULL,NULL );

// Add a new TEXT edit window

CreateWindowExW(WS_EX_CLIENTEDGE, TEXT("Edit"), NULL, WS_CHILD, 10, 10, 200, 25, hWnd, (HMENU) NULL,NULL,NULL );

Open in new window

I have really problems to understand makefile and its rules.
I created a makefile that works perfect. Now I want to remove objects before compile but it do not work with rm -f *.o
I get always the message "Missing seperator. stop"

# Build
# /opt/rh/devtoolset-4/root/user/bin/
    rm -f *.o

root := /usr/share/doc/xsd/examples

include $(root)/build/cxx/rules.make
include $(root)/build/xsd/tree-rules.make

XSDValidator: XSDValidator.o 05_bxf2.o
05_bxf2.o: 05_bxf2.cxx 05_bxf2.hxx
XSDValidator.o: XSDValidator.cpp 05_bxf2.hxx

Open in new window

Any Idea what I do wrong? Without "clean: rm-f *.o" it works well. I also tried to use a tab before "rm"
But nothing helps. It looks like "rm" do not work in makefile?
Hello All, I need help. Badly!

We have a Mercurial repo that keeps out source code for the last year. Yesterday, and error popped up when compiling one of the solutions (see compile_error.jpg). I then ran other projects from that same solution that did compile, and I get the runtime error seen in the file runtime_error.jpg. I then went back to a repo from September 2016, and I get the exact same compile time and runtime errors.

I have tried this on 4 systems. All four systems are Windows Pro 64 bit. I'm using VS2013 C++.

I don't suspect the code itself nor the repository. I'm thinking a Windows 7 update, or a VS update, or ???

Please help. I need ideas.

Thanks, Brian
I compiled my first app on Linux and I get an error:
./XSDValidator: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by ./XSDValidator)

Open in new window

I made a check:
strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX_3.4.1

Open in new window

And yes, it is not present. But how this error comes? I use gcc 5.1.0 is this the problem?

The software I compile use xerces-c as depency but this was installed with yum on my machine so I think it will not install things that link against a wrong libstdc++, right?

How to avoid this linking to an wrong libstdc++ ?
Hi, i wish if everyone is having a good day.
However i have an problem in mysql i would like to get the count of ids column in my table and plus 1 to the number how ever when i do like that it types +1 as string for example the result of counting was 3 it will add 3 to 1 like this 31 not 3+1=4 so i don't know how to solve this here's my code :

		String^ constring = L"datasource=...;port=...;username=...;password=..."; // Giving informations to the server
		MySqlConnection^ conDataBase = gcnew MySqlConnection(constring);
		MySqlCommand ^GetCount = gcnew MySqlCommand("Select Count(ID) from newdatabase.my_table;", conDataBase);
		MySqlDataReader^ myReader;
		MySqlCommand ^cmdDataBase;

		try {
			myReader = GetCount->ExecuteReader();
			while (myReader->Read()) {
				int Got = myReader->GetInt32(0);
				cmdDataBase = gcnew MySqlCommand("Insert into newdatabase.my_table (ID) Values ('" + Got+1 + "');", conDataBase);//queries
			myReader = cmdDataBase->ExecuteReader();
		catch (Exception ^Ex) {

Open in new window

Hi i was having some problems in finding the screen width and height how ever i am working on an project and i finally found

Open in new window

but every time i use this function in CLR i am getting this problem :
1>Width.obj : error LNK2028: unresolved token (0A00002E) "extern "C" int __stdcall GetSystemMetrics(int)" (?GetSystemMetrics@@$$J14YGHH@Z) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)
1>Width.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall GetSystemMetrics(int)" (?GetSystemMetrics@@$$J14YGHH@Z) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)

Open in new window

Isn't it supported in Clr ? if yes what i can use instead.
Hello everyone.

I've seen that what I'm trying to do which is monitoring the file IO require the use of Window File System Filter driver and I've also looked into it but was a bit hard to understands especially as I'm not a C++ developer. What I want to achieve is to be able to trap file copy, creation, as well as file sources and destinations, lets say I'm copying a file within my computer I want to get the source path of the file as well as destination path of the file and also the file name as well and if possible with the application that is sending the file.

I saw that this can also inform you if there is file access(opening of file, reading of file) this is very much important to me to also get it if possible while the request of file open is created. I wan to trap this and if the file is one of my file then I want to first work on the requested file first (decrypt).

Thank you.
Hi, Iam new to Linux and I have some problems compiling C++ code there.
A default "Hello World" software works fine. Compile and run well.

But now I want to add another code for XML and it looks like that I do something wrong in my makefile.

I use in my code:
# Build
root := /usr/share/doc/xsd/exmaples

include $(root)/build/cxx/rules.make
include $(root)/build/xsd/tree-rules.make

Open in new window

Bu the make/compiler give me the message that rules.make and other files cannot be found.
Can anyone help and explain what I did wrong?
We just moved from WinINET to WinHTTP. The latter does not have an equivalent InternetCanonicalizeUrl function.

The WinHTTP docs say that WinHTTPOpenRequest does this automatically but there is nothing there that specifically addresses this.

According to this reference you can use WinHTTPCreateURL which uses a URL_COMPONENTS structure to define the various URL parts. In the latter the lpszExtraInfo property is where you put the ?param=xyz& ... part.

Here is my problem - one of the parameters in the paramter string needs to be canonicalized as it could contain non-URL friendly characters (Example &).

With the WinINET version we used InternetCanonicalizeUrl on the specific URL parts which were then appended to the URL string.

If we have a URL now that looks like this
mydomain.com?param='Name & Surname','Description'

Open in new window

And we pass that to WinHTTPOpenRequest - it does not know that the & in Name & Surname is data and not a parameter separator.

How do we canonicalize individual parameters in the URL with WinHTTP
Hi Experts,

         I have a alpha numeric text of length (4096 to 8192)Bytes. I need a compression algorithm to compress and decompress text length upto (128 to 256)Bytes.

I have already tried some compression methods but not able to compress text upto (128 to 256)Bytes .
(eg: Zip.)

To perform this job we need only compression method not hash value.

Thanks In advance
language : c++
(tools : visual studio , acrobat reader)
thanks a lot
I am writing a REST client application using Embarcadero C++ builder Xe10.1 Berlin.
I need to have the REST server IP address configurable.
I have initially set the TRESTClient component BaseURL property to a known server IP address in the IDE. The BaseURL property value is and the application works just fine.
If I add code to change the BaseURL property however, the application doesn't respond and times out ?
Even if I use the value that works when set in the IDE, after the following code is run the application stops working ?

RESTClient1->BaseURL = u"";

Open in new window

Any ideas please ?
	 sql.Format("SELECT * INTO Sicherung_Thomas.dbo.LogBuch_%s FROM OMSDaten.dbo.LogBuch WHERE Zeitstempel>='%s' AND Zeitstempel<='%s'ORDER BY Zeitstempel ASC",str_tmp,str_loeschen_von,str_loeschen_bis);
	 _bstr_t bstrQuery(sql);
  	//Open the recordset object Tabelle 
    m_ptrRs->Open(_variant_t(bstrQuery),(LPCTSTR)m_strConnection, adOpenDynamic, adLockOptimistic, adCmdUnknown);
    //Get a pointer to the record-binding interface Coils
	if(FAILED(m_ptrRs->QueryInterface(__uuidof(IADORecordBinding),(LPVOID *)&m_piAdoRecordBinding)))     _com_issue_error(E_NOINTERFACE);

	   //---------- Any erros? -------------
    	catch (_com_error &e)
			//Display the error
        	GenerateError(e.Error(), e.Description());


	// Do we have a valid pointer to the record binding?
	if(m_piAdoRecordBinding) m_piAdoRecordBinding->Release();       
	//Set the recordset pointer to NULL
	m_ptrRs = NULL;     
	//Shut down the COM environment

void  CDatenbank_Anzeigen_Loeschen_Dialog::GenerateError(HRESULT hr, PWSTR pwszDescription)
	CString strError;
	//Format and display Error Message

Open in new window

Hi :)
This is my first post here and i hope to get an help :)
Anyway let's start with asking my question
my problem was that i only get 1 section name when using getprivateprofilesectionnames function
so i have searched a lot for an solution and i already found an solution but i don't actually understand how that works so could some one explain what's happening in the loop please ?

int main()
	char buffer[4096];
	GetPrivateProfileSectionNames(buffer, 4096, ".//SectionO.ini");

	char* Get = (char*)buffer;
	size_t length = 0;
	int nCnt = 0;
	while (*Get)
		length = strlen(Get);
		cout << nCnt << Get << endl;
		Get += length;
    return 0;

Open in new window

^ this is the code i have found can some one please explain what's happening in the loop ?
thanks guys.
MFC CComboBox won't display wide characters.
I'm using VS 2008, UNICODE is defined in the build and all of the prompts and other strings in the app are coming out fine.
The first try I just added the strings like any combobox and the display and dropdown showed a black line for each
character like the font was wrong.

I tried to SetFont to no avail.

I went to an owner-drawn combo box with no change.
The string shows correctly in the debugger (both in the watch and in the hover box).
the string is "Активна" and, copied from the debugger window,  shows up fine in WordPad.

In DrawItem I did:

      CString fontName;
      CDC dc;

//fontName is "MS Sans Serif" which is is expected and what I am using in the rest of my app and is reported to support Cyrillic.
//The rest is :

      CString thisString;
      GetLBText(lpDrawItemStruct->itemID, thisString);      

//note that at this point,  thisString shows to have the correct string in the debugger

      dc.TextOut(rc.left+iOffsetX, rc.top + iPosY,thisString);      

And I get " ||||||| "  in the combo box (both edit box and dropdown).

      dc.TextOut(rc.left+iOffsetX, rc.top + iPosY,L"TESTSTRING");
works fine.

Any ideas would be helpful...I've been working this way too long.
HOW TO CONVERT * char to string (linha):

const unsigned char
*menino1 = (const unsigned char *)0;

menino1 = p - 17;

string linha = menino[1]+menino[2]+menino[3]+menino[4]+menino[5];
I had this question after viewing C++ COM Method with Optional Arguments.

I am trying to produce a COM object in Visual C++, where one of the methods accepts optional arguments. Below are the interface declaration, the class implementing the interface, and the implementation of the method taking an optional argument. As it stands, it compiles. But when I try to call the function from an ASP page using VBS with the supposedly optional parameter missing, I get the following error

Microsoft VBScript runtime error '800a01c2'
Wrong number of arguments or invalid property assignment: comObject.ShowFinalSql

Following code in IDL
interface IWPharma : IDispatch{
   [id(2), helpstring("method ShowFinalSql")] HRESULT ShowFinalSql([in] BSTR query, [in] BSTR cleanup);

in C++:
    STDMETHOD(ShowFinalSql)(BSTR query, BSTR cleanup) override

in VB with error:
SET comObject = CreateObject("WPharma.Main")

REM Тест #1
comObject.ShowFinalSql "CHECK_SIGNATURES 01/01/2017", ""
Hi, does anyone have experience in this field? Where should we start as the beginners?

Many thanks as always!
Dear Team, can anyone show me where to begin with C++ in programming mobile apps?

I'm a newbie in C++ so if possible, pls give me links for the Beginners.

Many thanks in advance,
I am using Embarcadero C++ builder XE10.1 Berlin in an FMX application. How do I set the background colour in a TEdit control ?
I have a C++ builder code snippet below which I wish to use to display the cell values in a FMX TGrid component
The code gets called but the cell content is not displayed.
I suspect that this may be due to the TFillTextFlags not being initialised ? how do I do this or otherwise get the code to work ?
Also, how would I set the colour of the text being displayed by the fillText function ?



void __fastcall TForm1::Grid1DrawColumnCell(TObject *Sender, TCanvas * const Canvas,
		  TColumn * const Column, const TRectF &Bounds, const int Row,
		  const TValue &Value, const TGridDrawStates State)
	TValue v = Value;
	UnicodeString u = v.AsString();
	TFillTextFlags flags;
	Fmx::Types::TTextAlign ATextAlign;


Open in new window

I have a x64 shell extension for the context menu, which works fine. Only problem is; the icon does not show on the context menu. I have tried both InsertMenu and InsertMenuItem, but the icon does not show. Is there something else I have to do to make the icon appear in Windows Vista forward?






C++ is an intermediate-level general-purpose programming language, not to be confused with C or C#. It was developed as a set of extensions to the C programming language to improve type-safety and add support for automatic resource management, object-orientation, generic programming, and exception handling, among other features.