Go Premium for a chance to win a PS4. Enter to Win

x

C++

57K

Solutions

24K

Contributors

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

cplusplus.jpg
This jovial programmer is Paul Kent.  I just published his new course on C++.  Great job, Paul!

https://www.experts-exchange.com/courses/1401/Programming-for-You-Introduction-to-C.html

Note: This is a paid course.
0
Industry Leaders: We Want Your Opinion!
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Hello

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
0
So i have a program which filters a file containing "emails" in a single line, i link you to the exercise (it is a pdf) https://training.olinfo.it/#/task/ioit_spam/statement so my problem is that it doesn't accomplish all of the 4 tasks but from my tests (i've created a file with 1000 emails) it should correctly and pass all of its cases. i don't know if it's a problem of the corrector on the site (you need to register to test the program) but i link here the scoring (it should score 100 in theory) it might be a problem of the corrector? https://imgur.com/a/QmeY5 and the source file is this https://pastebin.com/iVPXUjxb
Thanks to everyone answering i hope i've made the question clear, the program works in my machine, it can even scan 10000 emails if i'd want to, infact i've tried filtering a 8mb file containing 1000 emails with 1000 words each.
this is the link for the 1000 emails input file https://drive.google.com/file/d/1f9OWkzZ_i9T8s6BcNIq5hXqBogCR2Dcj/view?usp=sharing
0
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.
0
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
{
public:
	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;
	};

	static
    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;
	}

private:
	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.
0
Hi!!!
I was going to send a struct from a client to a server using boost::asio::async_write_some, in this case boost::serialization and boost::property_tree come to help,
//boost::serialization
struct blank
{
    int m_id;
    std::string m_message;

    template<typename archive>
    void serialize(archive& ar, const short version)
    {
        ar & m_id;
        ar & m_message;
    }
};

blank info;

info.m_id = 1;
info.m_name = "Rasul";

std::stringstream ss;
boost::archive::binary_oarchive out_archive(ss);

out_archive << info;

Open in new window


So, now how can I send/receive out_archive using boost::asio asynchronously .. or
//boost::property_tree
boost::property_tree::ptree root;
root.put("id", 2);
root.put("name", "Rasul");

Open in new window

How can I send/receive root using boost::asio asynchronously??? (If you have some other ideas please share them)
0
hello everyone!
Ive been learning boost library, particularly boost.asio. So i decided to make a simple server and as i wanted to transfer a struct, i used boost.serialization but the problem is i was going to call doChat in doChat which asynchronously receives a string archive and deserialize it, my server crashes but if i receive a number (PODType) its OK

class server
        {
            void startAccept() {...} /// accepting a new client asynchronously and call handleAccept as a callback
            void handleAccept(const boost::system::error_code& ec, 
                                 std::shared_ptr<client> connection)
              {
                  if (ec == 0)
                  {
                      doChat(connection);
                  }
              }

              void doChat(std::shared_ptr<client> connection)
              {
                  boost::asio::async_read_until(connection->m_sock, 
                        connection->m_stream_buffer, '\n',
                      [this, connection](const boost::system::error_code& ec, 
                          std::size_t bytes)
                  {
                      if (ec == 0)
                      {
                          {
                              boost::archive::binary_iarchive in_archive
                                     (connection->m_stream_buffer);

                              in_archive >> connection->m_info;
                          }
                          cout << "ID:

Open in new window

0
#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->data=data;
					
					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;
			  
			  
			   push(&head,5);
			   push(&head,10);
			   push(&head,19);
			   
			   cout << "Linked list is:"<<endl;
			   
			   display(head);
			   cout <<"The minimum element in linked list :"<<endl;
			   cout << small(head) <<endl;
			   
			   
			   return 0;
			   }

Open in new window

0
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 …
1
visual c++ 2015 setup failed! 0X80240017 -  Unspecified error
windows server 2008 R2 Enteprise
0
Concerto Cloud for Software Providers & ISVs
LVL 5
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Hello Experts,

I have a MFC application that displays a dialog form. On a selection by the user, I need to open another form that the user will enter information into. This second form is semi-dynamic in the sense that when the user makes their selection, the items in the second form are changed before showing it. The user will interact with the second form.

I was thinking I would use a Tab control and make one page my original form, and put the interactive form on a second page, but it seems that all the components end up on one page.

I thought about laying out both forms on the same dialog and hide the components that are not needed for the currently active form. That method seems ridiculous.

Also, the second form can (probable should) be in a DLL that I can load that creates it.

Any ideas? Please show all code needed. I am up against a deadline.

Thanks, Brian

System:
Windows 7 Pro 64
VS2013 C++
0
I had this question after viewing Overlay a dialog box from a dll.
0
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.
0
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?
0
Generally, I will be given a set of X/Y points and their corresponding Z values. (Z = f(X, Y).
And those X/Y points are typically fall into a regular grid pattern so that a set of horizontal lines and vertical lines will capture all the points where those lines intersect. (Note: FYI - the distance between parallel lines do not have to be fixed to have regular grids.)

For the above, I can use bicubic spline interpolation algorithms to solve the problem. This approach requires solving for 16 coefficients of a cubic surface in every rectangle; and trying to keep the surface smooth at the end points by keeping the derivatives, fx, fy, and fxy, the same for neighboring rectangles.

a. Then there is a relaxation of this strict rule. It is that the horizontal lines (representing Y values) will be evenly spaced; but that the X values from one horizontal line to the next will not be regular (i.e., vertical lines intersecting the horizontal lines will not always have known X/Y points).

b. Then there is a more general case where the X/Y points are not quite regular. They aren't randomly placed, but they are not regular.
https://en.wikipedia.org/wiki/Multivariate_interpolation

If you can help me understand how to interpolate with either case (a) or (b), I would appreciate the help. One thought I had was to consider a point and look at 4 quadrants, and take the closest point in each quadrant, and using those 4 irregularly place points, try to interpolate. If (a) is a lot …
0
gdb.png
So what I'm trying to figure out is the cmp command. So this is a C program that asks for user input ID and Password and checks to see if it's correct. I'm suppose to change the bytes using C++ so that it'll accept the password that I input. So I want to know if the command cmp 0x74 %al means that it's comparing address at x76 with the bytes %al? I'm not too familiar with assembly code x86.
0
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 …
0
i want to create one dialog control with three buttons dynamically and  same dialog to created dynamically again 12 dialog s with the same content and size  but 12 dialogs control  should appear tile in format.
0
Due to security concerns related to updates not being applied to third-party software libraries, we are trying to replace as many of these as possible with functionality provided by the operating systems and are looking into options with compression. Are there any common compression formats that both Linux and Windows understand and provide C or C++-callable functions to programs to compress to and decompress from using only the APIs provided by the operating systems as installed? Thanks for any information!
0
[Webinar] Cloud and Mobile-First Strategy
LVL 11
[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Background: i work in a red hat and Windows 10 environment. We have models written in Matlab and Simulink that the developers will convert to C++ in order to get higher speed simulations. We do not like the C++ code that can be generated from these two products. We have a simulation proprietary framework which provides us with many math APIs for C++.

We currently use C++03 with Visual Studio 2010 and g++. Lead developer has no experience with C++11 but he would like to convince a large community of divisions to upgrade to C++11 . I asked him what skill levels of developers would he be bringing in . He said his group cannot afford the best, and he believes that C++ 11 is more complicated than C++ 03. Recently I've been doing this survey of multithreading capabilities in C++11, boost, Pthreads, WIN APIs , and while I can see that C++11 features are rich , they are also complicated to use correctly . For example if you want to squeeze performance out of a program that uses many cores , then you have to learn about the C++11 memory model, and be aware of all the tricky race conditions that can occur when the high-level code is done out of order as result of compiler optimization .

 Could someone give me a list of C++11 features that an average C++ developer could use and explain how it is beneficial with a strong argument that we convince a large community of divisions to agree to upgrade to C++11 .

 Two items that come to mind are multithreading and dimensional …
0
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 ?
0
how to create a user interface thread in mfc and UI thread will display  the  four times the dialog box should open.
0
Bloom Filter
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data definitely won't be found. Read on to find out more...
5
Hello!

I am a new member and I saw that you already have some old posts regarding dxf libraries.
I found the topics very useful for my search but they are a bit old.
For this reason, I am creating a new post for new suggestions and ideas!

I am searching for C++ (or C) libraries which can read dxf files, preferably all versions.
I have an issue with the license type as I want to use it for a commercial software.
So, I need a library with license MIT, 3-clause BSD or commercial.

I would be grateful if you have any ideas!
Thank you very much for reading this post.
0
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?
0

C++

57K

Solutions

24K

Contributors

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.