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

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
Independent Software Vendors: We Want Your Opinion
Independent Software Vendors: 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!

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
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
visual c++ 2015 setup failed! 0X80240017 -  Unspecified error
windows server 2008 R2 Enteprise
0
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
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
Ask an Anonymous Question!
LVL 11
Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

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
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
how to create a user interface thread in mfc and UI thread will display  the  four times the dialog box should open.
0
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
ORACLE & C++ connectivity in windows
0
Here is the tutorial I followed to get this far:
https://www.experts-exchange.com/articles/1132/Browser-Bot-Automate-Browsing-Sequences-With-C-PART-ONE.html#c2064546

What I'm doing is using an embedded web browser to interact with an HTML page.

In my code I'd like to set a checkbox to checked.


I'm trying to use an web browser object in MFC to interact with a website and check a checkbox.

I have a function that gets the DOM object and then where I'm struggling is using the interface to select the checkbox.  I've been able to interact with textfields and buttons no issue. Just the checkbox that's killing me.
My elementFromID function basically does this

   
 pDisp->QueryInterface(nTypeIID, (void**)&pElement);

Open in new window


Where nTypeIID is IID_IHTMLElement or whatever 2nd param is passed in.
pElement is what is returnedback.


   
So getting the element isn't the issue, it's interacting with it.
No where in the MSDN documentation can I find where it says how to set a checkbox value.

   
 void* pElem = ElementFromID(L"checkbox_id", IID_IHTMLElement);
	if (pElem != nullptr)
	{
		IHTMLElement* pCheckbox = (IHTMLElement*)pElem;
		VARIANT checked;
		checked.boolVal = true;
		checked.vt = VT_BOOL;
		pCheckbox->setAttribute(L"checked", checked, FALSE);

        // Alternate approaches that failed
        /*pElem = ElementFromID(L"order_terms", IID_IHTMLInputElement);
		IHTMLInputElement* pCheckbox = (IHTMLInputElement*)pElem;
		

Open in new window

0
Hi! I've been programming for several years in Delphi, then C++Builder but recently I started programming concurrrently(threads)
I've read on documentation VCL should be used by "synchronice" method. My question: all of the objects from VCL should be
treated within a Synchronice call or only when severals threads use the same object or only when they affect the GUI(labels, buttons
and others properties)?. Suppose I have n threads but each one of them use their own objects(labels, tlistbox, etc) inside a TPage for each one, so there's a TPageControl for all of them should I use Synchronize?
0
Free Tool: Subnet Calculator
LVL 11
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

I'm using currently the project
https://support.microsoft.com/de-de/help/246227/sample-secumgr-exe-overrides-security-manager-for-webbrowser-host
to check if a web portal, for example http://fontello.com/, works fine with EOT, WOFF and TTF to displaying different icons.

It looks like fonts with the Content-Type application/vnd.ms-fontobject or application/font-woff could not be used with IWebBrowser2.
In the webtraffic i could see, that the app could download the fonts, but after the download i received the error E_ABORT in the IHttpNegotiate::OnResponse handler.

The web pages works in IE, but when we disable font download in the security settings we get the same 'problem' with the IE.

I tried to enable the font download in function IInternetSecurityManager::ProcessUrlAction
(URLACTION_HTML_FONT_DOWNLOAD) without a positive result.

What i'm doing wrong?
0
I want to call a C++ project from Ruby, but my knowledge of the C build process is shaky at best, so unsure of how to set compiler flags (and why) as well as how to reference and link the project files. Currently RubyInline seems like the quickest option, but open to other suggestions.
0
Dear All

We have upgraded out website which is using C++ ATL COM DLL, from Windows 2003 server to Windows 2008 server.
 In 2003 server we have IIS 6 while in windows 2008 server we have IIS 7 version.
In Windows 2003 server site was working perfectly while in 2008 server, it started giving issue like session are losing its value.

One reason of loosing values of session is 'Restarting of Application pool', but not getting reason of this.

Can anyways please help me for letting me know what all can be the reason of this issue?

Regards,
Bytech
0
I have a short meta-programming approach for POD type safety from a previous question:
https://www.experts-exchange.com/questions/29056989/C-03-Templatize-Type-Safety-Enforcement-Part-2.html

I see the benefits of meta-programming as simplifying the development process for units - I believe that all new developers would have to do is to include a units header file, and follow a simple recipe for defining new data types.

I wrote in that question:
Other dimensional analysis areas that I am leaning towards:
 1. Make the class name part of the template
 2. Make the set of enumeration values part of the template so that they are not universally available
 3. Be able to operate on two different families of units. One obvious example would be:
        "distance (meters) = rate (meters/sec) * time (sec)".
     But we will have many other cross-unit operations as well.

I thought that I may as well see if I can get some tips on these ideas. If these 3 goals are realistic, but too much for one question, I am happy to work on what is reasonable for one question.

At the moment, I have to transcribe the previous question to my workstation, and then sell the ideas here and from the previous question to my lead software developer. The PM and Systems Engineer definitely like the idea of POD type safety. I just hope the lead likes the template approach.
0
How to insert image or picture in turbo c
Plz me
0
Can someone help me write this program in c++?

 Suppose a teacher weights the four exams he gives 10%, 25%, 30%, and 35%.
Write a program that reads ten sets of four grades, prints the weighted average of each set, and prints the unweighted average of each test. The number of students should be in a global constant.

I know I need to use a for loop, but I'm not sure how to write it. Can someone show me how to code this along with guiding me through the code?
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.