# 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.

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");
{
//OK, we now dissallow the app to start twice but we need the possibility to push up the existing window.
exit(0);
}


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");
{
//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

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


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


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


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


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;

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/write.hpp>
#include <boost/bind.hpp>
#include <iostream>
#include <string>

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),
heartbeat_timer_(io_context)
{
}

void start(tcp::resolver::results_type

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"

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 ?

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?

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!

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
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 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.

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

}

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

0
Hi Experts,

Can Indy use SSL with POP3 Client? I am looking for a solid example of code of using Indy POP3 with SSL to retrieve messages. I need it to be in C++ Embarcadero RAD 10.3.

All the best,

MusicBuddha.
0
Hello Experts,

Currently I have the following:

APP_A is a C# Win Form

APP_HW  is a C++ Windows Application that exposes various COM classes

This works fine, and APP_A can use the COM classes from APP_HW.

Now I want to change APP_HW from a C++ application to a C# WinForm application (I'll call it APP_HW_CS) and expose COM classes from it that can be used by APP_A. However, I do not want to use Reflection to achieve this. Reflection will just load APP_HW_CS for APP_A to use,  and I need to have APP_A link to a running APP_HW_CS for it's COM classes.

I have read a lot of information online. I have a COM object that is registered and exported from the APP_HW_CS (C# version). But the only way to use it appears to add the APP__HW_CS as a reference and then create the objects. But putting it as a reference seems to make it load a new version of APP_HW_CS and not use the running APP_HW_CS.

Is what I am trying to do even possible?

Thanks for any help and any references you can point me too.

Brian.
Using VS2013 on Windows 7 Pro 64bit.
Compiliing as a 32bit app.
0
I have in my API a value mapping:

cParams.nVerifyBufferSize = (int32)Params->VerifyBufferSize;


How is the best way to make sure that there is a valid value given? Like
Params->VerifyBufferSize

is possible invalid (nothing) I want to give 1 if not a valid value.
Any suggestion?  Wiath a boolean value I use

Params->FullCapacity ? BS_TRUE : BS_FALSE;


I think is a  goodsolution, isn't it? Something similar for VerifyBufferSize is needed

I use this inside a dotNet component.
0
My question is how to use C++ string  under Digital Mars.. I have downloaded the zipped packages: dmc587c.zip and stlport.zip. Not really knowing how to properly install them together other than just unzipped the folders, I tried a command line compiling the following code, which used to work though, simply with:

> ...\bin\dmc.exe   goesto4.cpp...

But I got "file not found"  error message for the  included <string> file.  Could anyone provide an example how to compile/link codes that use C++ string class?

#include <string>
#include <math.h>

int number_of_letters = 0;

string ones[10] = {"zero","one","two","three","four","five","six","seven","eight","nine"};

Thanks

Ze
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.