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

Is it possible to create an overlay on an iOS device that does not interact with an application? I am a newbie at programming and wanted to know if SwiftUI can accomplish this?
0
Because, the comvisible did not work, I would like to make a c++ wrapper, to call my c# dll functions.
0
SMTP How pro-grammatically set a specific outgoing email importance so that (for example) OutLook would flag it as a "Red" category.
   
 I am using libCURL  and assumed there would be a curl_easy_setopt() function to do it but have not found it yet.
0
SMTP how to set the outgoing email priority to Urgent using libcurl?     something like curl_easy_setopt(curl, ??,??);
0
Write a program to convert the time from 24-hour notation to 12-hour notation and vice versa. Your program must be menu driven, giving the user the choice of converting the time between the two notations. Furthermore, your program must contain at least the following functions: a function to convert the time from 24-hour notation to 12-hour notation, a function to convert the time from 12-hour notation to 24-hour notation, a function to display the choices, and function(s) to display the results. (For 12-hour time notation, your program must display AM or PM.)
0
Command line: C:\Python38>Scripts\pip.exe install pymqi-1.9.2.tar.gz
Result:
Processing c:\python38\pymqi-1.9.2.tar.gz
Installing collected packages: pymqi
  Running setup.py install for pymqi ... error
    ERROR: Command errored out with exit status 1:
     command: 'c:\python38\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\meedo\\AppData\\Local\\Temp\\pip-req-build-88aqs8jm\\setup.py'"'"'; __file__='"'"'C:\\Users\\meedo\\AppData\\Local\\Temp\\pip-req-build-88aqs8jm\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\meedo\AppData\Local\Temp\pip-record-m95ci6yz\install-record.txt' --single-version-externally-managed --compile
         cwd: C:\Users\meedo\AppData\Local\Temp\pip-req-build-88aqs8jm\
    Complete output (15 lines):
    Building PyMQI client 64bits
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.8
    creating build\lib.win-amd64-3.8\pymqi
    copying pymqi\__init__.py -> build\lib.win-amd64-3.8\pymqi
    copying pymqi\CMQC.py -> build\lib.win-amd64-3.8\pymqi
    copying pymqi\CMQCFC.py -> build\lib.win-amd64-3.8\pymqi
    copying pymqi\CMQXC.py -> build\lib.win-amd64-3.8\pymqi
    copying pymqi\CMQZC.py -> build\lib.win-amd64-3.8\pymqi
    running build_ext
    building 'pymqi.pymqe' …
0
In my QT I added a function to avoid double startup of the app. I decided to use a memory compare function
This looks like:

    QSharedMemory shared("61BB200D-3579-453e-9044-#58");
    if(!shared.create(512,QSharedMemory::ReadWrite)==true)
    {
        //OK, we now dissallow the app to start twice but we need the possibility to push up the existing window.
        exit(0);
    }

Open in new window


The problem is that this function is not working very good. If I start my app in QTCreator it looks like that his memory block exists all the time, also if I
stop the app. This course very often with Debug. Then I have to increase the last number to bring the app to start.

Do I miss something when end the app?

The whole main.cpp looks like
#include "mainwindow.h"
#include <QApplication>
#include <QTranslator>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QSharedMemory shared("61BB200D-3579-453e-9044-#58");
    if(!shared.create(512,QSharedMemory::ReadWrite)==true)
    {
        //OK, we now dissallow the app to start twice but we need the possibility to push up the existing window.
        exit(0);
    }

    auto teststyle = R"(
                   QGroupBox{
                     font-size: 13px;
                     font-weight: bold;
                     }
                   )";


    a.setStyleSheet(teststyle);
    a.setApplicationVersion(APP_VERSION);

    QTranslator pr;

    QSettings settings("IFoerster", "Diskbutler");
    int 

Open in new window

0
In my QT app I have a global class to show error messages.  This is working well in common functions.

int32 MdiChildHex::startHex(QString strBurnDrive)
{
    int32 ret = ::SetBurnDevice(strBurnDrive.at(0).toLatin1());
    if(showDiskbutlerMessage(ret, this)==false) {
        thisSuccessfullCreated = false;
        return;
    }
}

Open in new window


But if the function will hold a "const" in it, the function is not recognized-

int32 MdiChildHex::ReadSector(int32 sectorIndex) const
{
    char *buf = new char[2352];
    QByteArray mdata;

    int32 ret = ::ReadSectors(BS_CURRENT_DEVICE, sectorIndex, 1, BS_IMG_ISO, buf, bufferSize);
    showDiskbutlerMessage(ret, this);

    QByteArray byteArray = QByteArray::fromRawData(buf, bufferSize);

    hexView->clear();

    hexView->setData(new QHexView::DataStorageArray(byteArray));

    return ret;
}

Open in new window


The message I see in QTCreator is:
mdichild_hex.cpp:116:5: error: no matching function for call to 'showDiskbutlerMessage'
messanger.h:7:6: note: candidate function not viable: no known conversion from 'const MdiChildHex *' to 'QWidget *' for 2nd argument

message.h
#ifndef MESSANGER_H
#define MESSANGER_H

#include <QtWidgets>
#include "FoxSDKExport.h"

bool showDiskbutlerMessage(int32 nError, QWidget* parent);

#endif // MESSANGER_H

Open in new window


message.cpp
#include "messanger.h"
#include "utils_common.h"
#include <QMessageBox>


bool showDiskbutlerMessage(int32 nError, QWidget* parent){

    if (nError != BS_SDK_ERROR_NO){

        TCHAR chError[2048];
        int32 nLength = 2048;

        ::GetText(nError,chError, &nLength);

        QString errDesc;
#if defined (WIN32)
        errDesc= QString::fromUtf16(chError);
#else
        errDesc= QString::fromUtf8(chError);
#endif

        QMessageBox::information(getMainWindow(),  QWidget::tr("Diskbutler Error"),
                                  errDesc);
        return false;
    }

    return true;
}

Open in new window


What is the secret here with const?
0
Is it possible to recompile a program using increasingly newer compilers to "update" it?

We have a very old program that was compiled using Borland C++ around 1998, Borland C++ v3.1 to be specific.  I know it is ancient, but the program has become central to the business.  I'm not a programmer/developer but I'm trying to piece a little of this together.  Is it possible to use a newer compiler, maybe one or versions newer and recompile?  If we did that would that have any useful effect on the program?  
Here is what I want to do in the VERY SHORT TERM.
"upgrade" the program to work on a 64 BIT OS.  Right now it will only run on 32 bit XP or Windows 7.  32 bit Windows 10 will not work.  I would prefer to get it to work on Windows 10 64 so we can get away from the Windows 7 at 32 bit or Windows 7 at 64 bit with an XP mode on it.  
If possible I would also like to change how it sends to printers.  I'm not sure where in the program it does that, but it will only print to HP printers that are using LPT1.  I would like to allow it to print to the default printer.

Any suggestions for a NON PROGRAMMER to pursue?

Thanks.
0
I'm using C++,  WxWdigets and Ubuntu and sometimes my application needs to send TCP packets to a TCP server.
The packets are in this format:
std::array<uint8_t, 8> command1;

Open in new window

I'm using a non-blocking TCP client method from boost asio and it works pretty well.
The problem is that I need to change the content of command1 since I need to send 32 different values depending on users actions.

At the moment, I connect to the server by using start_connection() function which connects to the server and execute the function start_write(int scelta) which sends the command1 over the net.

I would like to call the start_connection() function by passing the value of command1 in order to send it with start_write() function.
Is there any solution to do this?
Or, is there a smarter and faster solution to acquire what I need?

#include <boost/asio/buffer.hpp>
#include <boost/asio/io_context.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/read_until.hpp>
#include <boost/asio/steady_timer.hpp>
#include <boost/asio/write.hpp>
#include <boost/bind.hpp>
#include <iostream>
#include <string>

using boost::asio::steady_timer;
using boost::asio::ip::tcp;

std::array<uint8_t, 8> command1;

class client
{
public:
  client(boost::asio::io_context& io_context)
    : stopped_(false),
      socket_(io_context),
      deadline_(io_context),
      heartbeat_timer_(io_context)
  {
  }

 
  void start(tcp::resolver::results_type

Open in new window

0
I'm using WxWidgets 3.1.2 with C++ under Ubuntu to control a device which acts like a Kiosk/ATM.
I use a magnetic card reader to take inputs from the users within the first frame (ProjectMain.cpp) and then I have two other frames (SecondPage.cpp and ThirdPage.cpp) where the users can perform some actions (i.e. press buttons, insert text and so on).
At the end of this procedure, the application destroys the third frame and reloads the first frame to start a new operation with a new user.

I use wx/timer.h in order to trigger a reset function if the user do nothing for more than 5 minutes; after this time, I load the first frame again.
I put the time trigger function in the frame creation function so the timer starts as soon as the frame is loaded; I use the trigger also when some buttons are pressed.
It works very fine, but sometimes I noticed that the application resets by itself (even if T << 5 minutes) and it loads new windows in the application bar.
If I press ALT+TAB, I can see several instances of the same application and this is very strange to me.

I'm pretty sure the problem is related to the timer function, but I cannot understand how to solve it.
Can you help me, please? I need to solve this problem very urgently, but I don't know what do do.

P.S. Moreover, when only the first frame is loaded, I can see that the timer on the secondpage starts, too. But, how can this possible since Frame2 is not loded yet?

ProjectApp.cpp
#include "ProjectApp.h"

Open in new window

0
Hi,

   I have called third-party  api from main thread in c++ on linux which is working fine as expected. But, when I call same api from child thread, it's failing in multi threaded application.

   technically what could be the reason? (not interested to check with third-party people).

Thanks,
bvm
0
I'm getting the following linker error when building a solution for a Visual Studio 2019 windows console program...

Error      LNK2001      unresolved external symbol "public: virtual void __thiscall kymeta::sensor::API::StartServiceA(void)const " (?StartServiceA@API@sensor@kymeta@@UBEXXZ)

I have no method in my code that is named 'StartServiceA'. Where is this coming from?
0
Hello,
  We have a PCL-1712 PCI Data aquicision device (DAQ). I want to get the data from analog input and pass the to analog output in almost realtime. The DaqNavi SDK contains and DAQ Emulator which you can use for programming/test. Since the SDK is buggy with Delphi it needs to be done in MFC/C++.

Anyone can program it ?

SDK Link: https://support.advantech.com/support/DownloadSRDetail_New.aspx?SR_ID=1-13L33UP&Doc_Source=Download

Thank you
0
Hello all;
I have a C++ Embarcadero Project which use DevExpress Components; When I try to compile it, I have à dialog which ask me for the path to static libraries:

dxMapControlRS17

dxGaugeControlRS17

dcldxMapControlRS17

dcldxGaugeControlRS17

I searched for these libraries everywhere, but unfortunately, i have found nothing even by googling these names, nothing!

What do you think? any suggestions?

Thanks in advance!
0
Hello;
I have a program c++ which call a Delphi DLL; The Delphi DLL has to inform the program c++ by the result of his work several times during his lifecycle.

in yours opinions what are the possibles methods for doing this? without using files ou databases like a third part!

Thanks in advance.

I will list here what i think:

- First idea is by passing a pointer to delphi dll when launching it; but i don't know which types to use in the two sides and how Delphi treat pointers!

- Second idea is by using an intermediate c++ DLL; Delphi will call a function in the DLL C++ which will modify the values of the c++ dll variables. in the other side, when the c++ program launch the c++ dll, it will pass a pointer. When delphi call the c++ function, the function will fill the pointer passed by c++ program. Do you think that works?

I don't know if i was clear; Thank you
0
Hello!

I am a beginner in programming by C ++. This is my first question on EE also.

I am learning the book of Bjarne Stroustrup "Programming. Principles and Practice Using C ++".
I'm using MS Visual Studio 2019 for creation of C ++ programs.

I am performing following exercise:
“Define an Order class with (customer) name, address, data, and vector<Purchase> members. Purchase is a class with a (product) name, unit_price, and count members. Define a mechanism for reading and writing Orders to and from a file. Define a mechanism for printing Orders. Create a file of at least ten Orders, read it into a vector<Order>, sort it by name (of customer), and write it back out to file. Create another file of at least ten Orders of which about a third arc the same as in the first file, read it into a list<Order>, sort it by address (of customer), and write it back out to file. Merge the two files into a third using std:: merge().”
I wrote the program consisting of the following files:
1.      std_lib_facilities.h
Header file from B.Stroustrup
2.      Exersize_9.h
This file contains declarations of functions.
3.      Address_definition_file.cpp , Date_definitions_file_.cpp, Order_definitions_file.cpp, Purchase_definition_file.cpp
These files contain definitions of functions
4.      Exersize_9.cpp
This is a main file.
5.      File_input.txt
Input data are in this file. For an example, I took three objects
6.      File_output.txt
 Result data are in this file

And at last problem:
0
When I try to run roxio nxt 7, I receive this error: Roxio-VideoWave---Error---2019-08-05.pdf
0
I would like to solicit your help please.
I would like to call a specific C# feature from within a C++ programming environment, such as:
            Microsoft MSVC 2017 enterprise edition.  The specific C# specific is:          
                              System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable() method.

This is not a school project/assignment. From what I have looked at, there is a lot more programming required that I am not able to understand.  Could you help me out please.....  Thank you.
RSVP.   Thad.

This is what I have come up with...
 using System;
 using System.Collections.Generic;
 using System.IO;
 using System.Xml;

 using System.Net.NetworkInformation;  /// they say this "networkinformation stuff is C# material.
 public static BOOL IsAvailable(int * xx) {
       bool IsAvail;
       bool IsAvail = NetworkInterface.GetIsNetworkAvailable();
       *xx = IsAvail;
       return (IsAvail);
 }
0
I am using an Indy 10 UDP client component with Embarcadero C++ builder EX 10.1 Berlin

I need to determine the IP address of the local PC that received the broadcast packet (not the peer IP). there are two network cards.
The UDP client is bound to 0.0.0.0 port 13580

How do I determine the IP address of the Ethernet port that generated the event ?

void __fastcall TForm1::IdSystatUDPServer1UDPRead(TIdUDPListenerThread *AThread, const TIdBytes AData,
          TIdSocketHandle *ABinding)
{
	UnicodeString u;


	u = ABinding->IP; // this is the binding which is 0.0.0.0
 	u = AThread->Binding->IP; // I was expecting this to give what I want but it returns .0.0.0.0

	if(u == u"10.41.0.20")  // only use specified local ethernet port
{
.....
}
else
{ // handle differently if another network adapter received the data

}

Open in new window

1
Hi!

The application to be developed consists of Webserver and the TCP Server. The TCP server listens to specific port and keeps on sending Keepalive and messages. While the HTTP server accepts user input and send the data to the TCP Server. So my question here is whether the TCP server can act as the HTTP Server. If so how can this be scheived. I am using Poco C++ libraries for HTTP and TCP server If there is some example please can you guid me here.,
0
Hi,

  aws efs mounted (nfs 4) on rhel 7.4.  On my machine, I have ~10 mounts. How do I find whether it is efs mounted from us-east-1 or other mounts?  Is there any function or systemcall to find out from c or c++? Already tried with statvfs and statfs calls.

Thanks,
Bvm
0
I would like to see any examples of QuickReport 6.0 professional BarChart code for Embarcadero C++ Builder XE 10.1 berlin please ?
0
My application consists of  GUI application, an  application which resides on controller  and the server application. I am developing my application with C++ for the Poco libraries. The controller should communicate with the GUI and the server through the TCP /IP protocol. So My question here is whether I need to setup my GUI as server? If some one can forward me the sample of TCPServer created with Poco libraries which listens to specific ip adress and port.
0
From C++ how can I capture and iterate through the output results of an Oracle PL/SQL stored procedure that returns data as "TABLE of NUMBER(7)", or "TABLE of VARCHAR2(100)" etc?  I haven't found a clear example or documentation that details the accessing data returned as tables.
   I'm using the MS VC9++ (VS2008 SP1) with the Oracle 11.2 32-bit Instant Client. At this point I need to stay at these versions to not risk breaking the compilation of a much larger project with a lot of legacy hardware and drivers.  I've tried many variations that don't compile, or give runtime errors. Running OTT has prove problematic as the TYPE definitions only exist when the procedure is run.
   I'm currently using the OCCI interface but am open to using C++ .net if it will coexist with the current C++ code.

PL/SQL package definition

create or replace PACKAGE          "CARRIERPKG" AS
    TYPE tcarrier_site     is TABLE of NUMBER(7)      INDEX BY BINARY_INTEGER;
    TYPE tpart_serial      is TABLE of VARCHAR2(100)  INDEX BY BINARY_INTEGER;
    TYPE tpart_rtn_msg     is TABLE of VARCHAR(200)   INDEX BY BINARY_INTEGER;
   
 
      PROCEDURE get_parts_v12
      (p_carrier_serial	  IN  phase2.carrier_site.carrier_serial_num%TYPE,
       p_part_num         IN  phase2.part_info.PART_NUM%TYPE,
       p_carrier_type     IN  phase2.carrier_type.id%TYPE,
       carrier_site       OUT NOCOPY tcarrier_site,
       part_serial        OUT NOCOPY tpart_serial,
       rtn_msg            OUT 

Open in new window

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.