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 have coded a Windows 32 VCL application using Embarcadero C++ builder  EX10.1 Berlin and using a winsoft TOBR barcode recognition component.
The application worked.
I now wish to no longer use the Winsoft component in the application so I removed it from the project entirely,including the library and the obr.hpp header file.
The project now compiles but I get a linker error that the file OBR.OBJ cannot be found when the project no loger uses the component as far as I can see.
Where is the linker getting the reference to OBR.OBJ from or how can I get rid of the error ?

The ilink32 command line is as follows :

  c:\program files (x86)\embarcadero\studio\18.0\bin\ilink32.exe -G8 -L.\Win32\Debug;"c:\program files (x86)\embarcadero\studio\18.0\lib\Win32\debug";
  CivicWeldRESTServer;"c:\program files (x86)\embarcadero\studio\18.0\lib\win32\release";"c:\program files 
  (x86)\embarcadero\studio\18.0\lib\win32\release\psdk";C:\Users\Public\Documents\Embarcadero\Studio\18.0\DCP -j.\Win32\Debug;"c:\program files 
  (x86)\embarcadero\studio\18.0\lib\Win32\debug";CivicWeldRESTServer;"c:\program files (x86)\embarcadero\studio\18.0\lib\win32\release";"c:\program 
  files (x86)\embarcadero\studio\18.0\lib\win32\release\psdk";C:\Users\Public\Documents\Embarcadero\Studio\18.0\DCP -l.\Win32\Debug -C -v 

Open in new window

Free Tool: Site Down Detector
LVL 11
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Somewhere along the line, about when OOP came along, I was diverted into doing other things.  So, I lack the "cultural refinement" that must have come along with it.
I've written programs in C, C++, VBA, C#, and Fortran (of whatever recent vintage) but, I must admit, quit in starting on C# because there were all those class names that had no meaning for me.  I couldn't even debug an example program as a result!

I think I understand the general concepts - so that's not it.
It's the specifics that are elusive.
I've seen the same thing in VBA but seem to have been able to get things done.  It was sort of like "programming by example" as in "copy & paste".

I've researched it a bit but don't seem to find the answer.  So:
What is the key to understanding the Classes, what they're called and what they do, so that one can be relatively productive?  Does this come by osmosis?
It must be something like a dictionary....
Or, if the proper term is other than "Classes", can you enlighten me a bit please?
I am writing a windows Web application using embarcadero XE10.2 Berlin C++ builder;
The application uses a TWebModule and receives a POST web action from a web page being displayed on a remote mobile device.
the mobile device posts a jpeg image which Is received in the following function, st2 is a TMemoryStream.
I am copying the raw content into a TByteDyneArray b so that I can easily inspect it. I load the TMemoryStream with the raw content and then save the memory stream to a file with the extension .jpg.
This file is reported as corrupt or invalid or too long when I try to open it with windows Photo viewer or the like.
how do I extract the image data ?
The size of the raw data as given by  Request->RawContent.Length is
Inspection of the beginning of the raw content  up to encountering a NULL is shown in quotes below.
"------WebKitFormBoundary9lWvgPDQcTZoDcRf\r\nContent-Disposition: form-data; name=\"picture\"; filename=\"15123250544981385201258.jpg\"\r\nContent-Type: image/jpeg\r\n\r\n�￘�£\x02tExif"

void TWebModule1::Action3Post(TWebRequest *Request,TWebResponse *Response)
	UnicodeString u,v,uu="";
	TByteDynArray b;
	char buff='a';

	int n,m,w;
	u = Request->ContentType;
	n = Request->RawContent.Length;
	m = Request->Files->Count;
	b = Request->RawContent;
    st2->Position = soBeginning;

//	Form1->Memo1->Lines =  Request->ContentFields;

Open in new window

Hello all,

Using Borland C++ 4.52 on a Windows Virtual PC in XP Mode.

I am writing what I thought to be a pretty simple DOS program.  It is basically opening files, filling up structures, printing structure information to a file and that's it.  The files are binary and are less than 32 Kbytes, most are 1K or less.   I am 75% of the way done, it has been running fine up to now.  I just added some code to finish it off, and now I am getting this error at runtime:

"The NTDVM CPU has encountered an illegal instruction.
CS:00cc IP:0106 OP:ff ff 00 00 00 Choose 'Close' to terminate the application."

The thing is, the code I added is just a repeat of the same code that was at the beginning but to different structures.  Seems to have something to do with the code size?  I don't know.  I am not that familiar with memory management.  However, when I removed the stuff I had added, it works again.  

I am attaching both the main code and the extra code I am trying to add.

I would appreciate any guidance.
I have a friend who wants to learn to make video games.

I was wondering what to teach him , I was thinking of starting out with Dennis Ritchie’s “The C Programming language”

He wants to make a game within the next two years. That’s his goal.
I was trying to use wcstombs_s to convert my Japanese wstring into multibyte char but am getting empty string . Here's what i was doing my first approach using wcstombs_s -

wstring str = "ス";
char * outputString;
size_t outputSize = str.length() + 1; // +1 for null terminator
outputString = new char[outputSize];
size_t charsConverted = 0;
const wchar_t * inputW = str.c_str();
wcstombs_s(&charsConverted, outputString, outputSize, inputW, str.length());
i receive empty string in inputW,
Hi Experts,

I am using VB.Net, C#, VS 2015 along with various other com components written in C++ language plus various third-party DLL's. This is a window based application having a client-server architecture.

I know this seems like subjective question itself but appreciate if you could provide some guidance, challenges faced that one should take care while moving from 32-bit code base to 64-bit.

Looking forward to hearing from you guys.

I'm doing a C++ compiler project where I need to flag warnings at places where assignment operator (`=`) can be used wrongly instead of the comparison operator (`==`)...e.g
while doing comparison in `if` statement , to check variable `a` as `10` sometimes we wrongly type if(`a`= `10`), which will result in `if` statement always `true` whereas I wanted to be `true` only if `a` is `10`. Some of the cases I can think of are :
1. `if(var = a)`, logically it should be `if( var==a )`
2. `while(var = a )`
3. `for(;var=a;)`
4. `do{}while(var=a)`
5. `var=a? "some XYZ": "some ABC"`

Can you please help me with the more cases where this logical error can occur, where the user was supposed to use `==` and by mistake `=` was used?
I am trying to do a cryptography, but to no avail .... the code does not compile. How do I convert const char * buf to BYTE? Or is there another way?

#include <cstdio>
typedef unsigned char BYTE;
BYTE server_keys[2][256] = {
		0xFC, 0x77, 0xA1, 0x85, 0x1F, 0x30, 0x51, 0x20, 0x93, 0x4A, 0xE3, 0x10, 0x0E, 0x32, 0x58,
		0x64, 0x36, 0x8C, 0x19, 0xF0, 0x61, 0xE0, 0xDF, 0x9E, 0x9F, 0x90, 0xD0, 0x05, 0xFA, 0xEB,
		0x3D, 0x4B, 0xA5, 0xF1, 0x72, 0x73, 0xD4, 0xB5, 0x70, 0xD7, 0xCD, 0x9A, 0x95, 0x2B, 0xC9,
		0x00, 0x8E, 0xAC, 0x35, 0x1B, 0xE7, 0x7B, 0xC3, 0x15, 0x11, 0xF6, 0xAD, 0x5B, 0x87, 0x86,
		0xB4, 0x9B, 0x26, 0xDB, 0xDE, 0x1C, 0x66, 0x24, 0xD8, 0x27, 0x6A, 0xBD, 0x5D, 0x8D, 0x7D,
		0x0D, 0xAE, 0x8B, 0xA9, 0x62, 0x6B, 0x0B, 0xE2, 0x5C, 0x6C, 0xBE, 0x54, 0x55, 0x6E, 0xBF,
		0x3F, 0x88, 0x99, 0xB0, 0x48, 0x16, 0x5A, 0x34, 0xA6, 0xE8, 0xFD, 0xD3, 0xE4, 0x82, 0xD6,
		0x8A, 0x3B, 0xFE, 0xA4, 0x94, 0xF8, 0x06, 0x97, 0xCB, 0xF5, 0x33, 0x79, 0xD9, 0x83, 0x4F,
		0xB1, 0xAB, 0xA2, 0x69, 0x91, 0xFF, 0xC6, 0x2C, 0x68, 0xC1, 0xAA, 0xC4, 0x1D, 0x18, 0x3A,
		0xBC, 0x04, 0x2F, 0xA3, 0xFB, 0x17, 0x89, 0x25, 0x02, 0xCF, 0xDD, 0x2D, 0x6D, 0xC5, 0xC2,
		0x46, 0x01, 0xE5, 0xED, 0x2E, 0xDA, 0x31, 0x37, 0x40, 0xC8, 0xB6, 0xE9, 0x7C, 0x45, 0xF3,
		0x47, 0x22, 0xF9, 0x63, 0xB9, 0x13, 0x38, 0x78, 0x2A, 0xC0, 0xEC, 0xEF, 0x28, 0x12, 0x6F,
		0x75, 0xEA, 0x29, 0x84, 0x9C, 0x44, 0x96, 0x0A, 0x59, 0x76, 0x92, 0x41, 0xF2, 0x67, 0x08,
		0xB8, 0x43, 0xCA, 0x1E, 0xE1, 0x52, 0x3C, 0x42, 0xEE, 0xA8,

Open in new window

Hello! I am intercepting packets and want to encrypt them using a simple XOR. The packets are not being encrypted, where am I going wrong?

void process_send(SOCKET s, const char* buf, int *len, int flags) {

			char* q;
			char j = 0;
			int l = sizeof(buf);
			char k;
			int i;
			q = (char *)buf;
			k = q[4];			

			q[4] ^= 0x76;
			for(i = 5; i < l; i++)
			j = q[i];
			q[i] ^= k;
			k = j;

Open in new window

Help-me :/
Free Tool: Port Scanner
LVL 11
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Maybe a dumb question, but here goes: So, my C++ application uses GDI calls to draw pretty simple lines, arc, etc. overlaid on images.  I'd like to upgrade the look of those graphics -- maybe with something a bit more powerful than GDI that can maybe do anti-aliasing, or other things to make the overlaid lines and circles look better and cute.  So, I see talk of GDI+.  And I saw a post of a GDI+ example, and the calls look exactly like the calls that I have been referring to as "GDI" for years.   So, my application is MS VC++  and using IDS VS2015.   Its not .NET -- just C++ code, often quite close to C code actually.  So my questions:

1) Do I have to do something (link something or load something) to get GDI+?  Or is it just there, ready for me to start calling?
2) I believe I can call things in GDI+ from my non-.NET C++ code, correct?
3) Will I find some things in GDI+ that were not in GDI that will help me make my graphics (overlaid on images) look better, cuter?
4) Where do I find doc so I can look thru what is available in GDI+ ?


In C++, what is the most elegant way to check if an argv[i] is an integer? I prefer a short inbuilt check instead of writing a function that does something like traverse the char* and check if each element is a digit.

Any suggestions? thank you
I have been trying to pass a string to fetch the node and am successful for string with only single quote (') and only double quotes ("). But am unable to parse it when string contains both singe and double quotes. I have my string in CString as-

CString str=L("H'el"lo");
and all other combinations of these. Can you please tell me how to do in C++, i have seen the examples are in C# but that are not helping me out.

Here's the link for C# Encoding XPath Expressions with both single and double quotes

XmlNode n = doc.SelectSingleNode(“/root/emp[lname=" + str + "]“);
How should i make my str work for string containing both single and double quotes in any order.
Constraint: Cannot change from C++03 or C-88.

After some online search, I wrote the following program to see how to run a class non-static member function in a pthread via a static member helper. But I got the wrong answer. According to breakpoints, the DoSomething constructor is called once; yet on the 2nd call to doSomething, the initial values of val1 and val2 are set to 100, 200.0, respectively. Granted, I set the members of an internal struct to those values, but not to the class data members.

So, how did that happen; how do I get the args.retval return value from the pthread to end in 5 + 16 = 21 + a multiple of 100.
// header
class DoSomething
	DoSomething(int v1, float v2)
		: val1(v1), val2(v2) {
	retval = val2 - val1;

	float* doSomething(int v1, float v2) 
		val1 += v1;
		val2 += v2;
		retval = val1 + val2;
		return &retval;

	struct v1v2_s
		int v1;
		float v2;
		float retval;

    void* DS_helper(void* args)
		int v1 = ((v1v2_s*)args)->v1;
		float v2 = ((v1v2_s*)args)->v2;
		((v1v2_s*)args)->retval = *((DoSomething*)args)->doSomething(v1, v2);
		return args;

	int val1;
	float val2;
	float retval;

Open in new window

#include "DoSomething.h"

int main()
	DoSomething DS(2, 9);

	DS.doSomething(3, 7);

	DoSomething::v1v2_s args = {100, 200.0};

	pthread_t t;
	pthread_create(&t, NULL, DS.DS_helper, &args);
	pthread_join(t, (void**)&args);
	float res = args.retval;
	return 0;

Open in new window

If you could correct the existing code w/o trying to revamp the whole approach, I would appreciate that. (After this is done, then, sure, revamp the whole approach.)
Thanks in advance.
#include <iostream.h>
#include <bits/stdc++.h>

using namespace std;
	   struct Node
	       int data;
		   struct Node* next;
		   int small(struct Node* head)
		   int min = INT_MAX;
		   while (head != NULL)
		      if ( min > head->data)
			       min = head->data;
				   head = head->next;
				   return min;
				   void push (struct Node ** head ,int data)
				   	struct Node * newNode ;
					newNode->next = (*head);
					(*head) = newNode;
				   void display(struct Node* head)
				    while ( head != NULL ) 
					   printf("%d -> ", head->data);
                          head = head->next;
					cout << "NULL" << endl;
			int main()
			   int x;
			  struct Node* head = NULL;
			   cout << "Linked list is:"<<endl;
			   cout <<"The minimum element in linked list :"<<endl;
			   cout << small(head) <<endl;
			   return 0;

Open in new window

This isn't really a question; rather, it is a puzzle!!!

Please note, this is NOT an assignment of any kind (check my profile if you are unsure as to my tenure on the site). The idea is to spark some activity in the C/C++ topic areas and to have a little fun. Points will be awarded to the expert(s) who provide the most interesting solution. The idea is to have a little fun, promote discussion and have something interesting to think/talk about.

If this goes well, I plan on doing one of these types of puzzle questions on a regular(ish) basis. I would like to see expert colaboration, rather than experts just going gun-ho to get points. I will consider colaboration between experts when I finally award points. I will close this question once I believe it has reached a natural conclusion (ie. no futher productive activity).

So, let's start with the first puzzle. It's one that has been set many times before and I'd be interested in seeing different approaches to solving it. Please don't just search Google and copy/paste. I promise I will check and any plaigirised answers will be ignored (and probably deleted).

Let's go...

Your job is to write a program that, when run, outputs it's own source code (including comments) such that if the output was fed back into a compiler, built and run it would do exactly the same thing as the original program. The output must be word for word identical to the original source code, such that performing a diff between the original source …
I had this question after viewing Overlay a dialog box from a dll.
Will C++ and VB6 continue to work in newest versions of Windows?
We have some old program written in  C++ and VB6 and want to prioritise upgrading them to .NET.
If a new version of Windows will make them obsolete overnight then upgrading them is a high priority.  Otherwise not.
A similar question arises if processors move from 64 bit to 128 bit.
I have a program created using C++ that runs fine on all Windows 7 computers. But the application crashes on Windows 10 computers unless they select "Run as Administrator". This is a serious issue when distributing my software. Is there any way programmatically to allow the program to run in this hostile environment?
Prep for the ITIL® Foundation Certification Exam
LVL 11
Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

I first started out trying to learn C# but found out that in order to code the trading strategies and functions that we want, we would have to use this package called Sierra Charts

The developer I am working with is very familiar with SC and pointed me to this C++ Tutorial https://www.sierrachart.com/index.php?page=doc/AdvancedCustomStudyInterfaceAndLanguage.php#CPlusPlusReferences

This software looks rather dated in comparison to something like MultiCharts https://www.multicharts.com/net/ which uses .NET.

I might consider switching at some point to another platform like MC .net version, but in all my research, I see that C++ is the most prevalent among traders.  It is fast, which is the main consideration, and lots of pre-written functions already exist for it.

So I have switched my focus, since I am developing in C++ currently with SC, to learning the basics of C++ over C#.

I have been through the tutorial above and think I have absorbed just enough of it to barely understand what it is, but I am determined and now want to find a better tutorial that won't take me too far off base from what I am trying to do which is to code trading strategies.

I'd still like to learn the basics of C++ a little bit better before really getting my feet wet with Sierra Charts as I am currently letting my developer work on developing the function, which he is much better off doing, without my interference.

I'd like a tutorial for C++ that is much more interactive, lets me …
Below is a snippet from a REST server application that I have written in Embarcadero C++ builder XE10.1 Berlin

void TWebModule1::Action1Get(TWebRequest *Request,TWebResponse *Response)
  Code here generates some JSON response based on the Request.....

// send the response
Response->ContentType 	= u"application/json";
Response->Content       = ... some JSON text


Open in new window

I wish to modify the REST server so as to return some html text in another Action handler but I need to know the value to assign to the Response->ContentType instead of "application/json"
Also what other values are valid Response->ContentTypes ?
I have a desktop App written in MS VC++.  I'd like to add some video capability: show various formats, grab still frame, maybe very simple editing.  What kind of SDKs are available and good?  Is there a need for me to go to C# to get the latest/best, or can I stick with my familiar C++ world?
I had this question after viewing Obtaining help with programming tasks.

The parts of the C++ program according to the graphic below include:

Comments - ok

#include statement <iostream> preprocessor directive - ok
Example from our SierraCharts strategy:  #include "sierrachart.h"

using namespace std; - ok, ours might be a shared dll library reference instead?
Example from our SierraCharts strategy:
SCDLLName("TPStrat1 DLL")

int main () - ok, no idea here?
Example from our SierraCharts strategy:
bool IsNewBar(SCStudyInterfaceRef sc, int& PreviousIndex)
statements - ok, ours might be if (if else) statements only?

Before the first IF statement

C++ in general
I am not a programmer and would like some help with programming tasks as they relate to trading.

Specifically, my current developer is using C++ with SierraCharts to code a trading strategy, that looks for signals in a real-time stock chart, and then does a lookup to find specifically which underlying derivative call option to buy based on the signal obtained from the stock chart.

It turns out that not all trading platforms will support this kind of complexity.
SierraCharts allows a trader to use the raw code in a real programming language which is also part of the reason for the choice of platform.

It also turns out that in order to use the strategy, with SierraCharts, a would-be customer wouldn't have to pay as many platform costs to use it.

This is so complex that it has been difficult to connect with developers that can do this kind of work.

I need to better understand the structure of the code perhaps, in order to know where to go seek help because I am thinking that "anyone" with C++ knowledge might be capable of helping.

Is my current understanding of the below items correct?

Namespace - contains keywords specific to C++, and hold various libraries that contain functions
Library - there are proprietary and non-proprietary libraries ?
Functions - related to particular fields such as stock trading
Keywords - specific to C++ in general
I have a code snippet shown below which does not compile. I was of the understanding that Embarcadero C++ Builder XE10.1 Berlin supported the C++ 11 standard ? The initialisation of a vector gives a compile error:

[bcc32 Error] Unit1.cpp(22): E2131 Objects of type 'vector<int,allocator<int> >' cannot be initialized with { }
  Full parser context
    Unit1.cpp(20): parsing:  _fastcall TForm1::TForm1(TComponent *)

Code snippet:
#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
using namespace std;

#include <algorithm>
#include <list>
#include <vector>

#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;

__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
	std::vector<int> mem = {1,2,3};

Open in new window







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.