|
There are problems (memory leaks). You must delete memory allocated with new when not used anymore:
void CreateFolderPath(string Path)
{
char *strFolderPath = new char[Path.size() + 1];
strcpy_s(strFolderPath, Path.size() + 1, Path.c_str());
_mkdir(strFolderPath);
delete [] strFolderPath;
}
string ConvertIntToString(int cipher, int objintiger)
{
string temp;
char *Res = new char[cipher];
sprintf_s(Res, cipher, "%02d", objintiger);
temp = Res;
delete [] Res;
return temp;
}
For your first example there is even no need to copy the string. Just pass it to _mkdir() :
void CreateFolderPath(string Path)
{
_mkdir(Path.c_str());
}
|
|
|
|
|
Thank you very much!!!!
|
|
|
|
|
hi friends:
why c++ is still being used?!
|
|
|
|
|
Why shouldn't it be used anymore?
Your question is like asking why there are people still driving a Ford.
|
|
|
|
|
|
..because you can't program an OS in VB.NET.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Eddy Vluggen wrote: can't program an OS in VB.NET. You can't do that in C++ either, if you can then you can do so in JavaScript too.
Or even Python.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Afzaal Ahmad Zeeshan wrote: You can't do that in C++ either, if you can then you can do so in JavaScript too. Well, it is also not completely true.
Most parts of the modern OSes is made in C and C++. You don't write drivers in JavaScript, because most devices work faster than your average garbage collector. It at least needs a language that can compile to native, without dependencies.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Quote: Well, it is also not completely true. Because it was not meant to be. It was merely a rant, or joke.
Quote: Most parts of the modern OSes is made in C and C++ Most part comes from C, that contains Assembly in __asm or similar. C++ is just used to create most APIs, because you can provide a simple abstraction there. You can provide underlying implementation of the system and services, then you leave it in the hands of programmers.
Of course drivers need to be fast, but what a driver is merely a program in the forest of services running. Tree (program) can be a class, a forest is abstraction, and... You cannot do that easily in C — that is why we have demons in Linux and you can write in in any definition, there is nothing to implement, nothing to inherit and nothing to worry about.
Move a bit ahead, enter the realm of C++, Qt for instance, you need to write classes as inherited ones and then you can compile that across. Qt is used for driver development.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Afzaal Ahmad Zeeshan wrote: It was merely a rant, or joke. I already argue way too much here, so I'm not going to react
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Have an upvote for a smile then.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Wrong. C++ compiles down to machine code, so you can.
|
|
|
|
|
Like I said in that message, in this case, so does JavaScript, Python or any other language.
I wonder if there is a library for translation of shell script to a machine code — highly doubted statement.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
No, you said: "You can't do that in C++ either, if you can then you can do so in JavaScript too"
C++ does compile down to machine code, script languages dont, they are interpreted.
|
|
|
|
|
|
Richard Deeming wrote: Are you sure about that? Already corrected it, remembering Cosmos.
I also remember it not being a commercial success
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
But the interpreter the VB Net code will be running on will be written in C or C++ because to run on actual hardware you have to run the instruction set that hardware exposes. You can only do that in a compiled language.
|
|
|
|
|
babak1110 wrote: why c++ is still being used?! Because not everyone is programming desktop GUI apps, and not everyone hates OOP.
C++ provides an object-oriented programming model for C environments. C is Assembly language with a better syntax. So, it means you can do more of hardware programming easily, registers are available etc. C++ was created by Bjarne to include "classes", because he had experience in Simula, which was object-oriented.
C was not, so C++ was created to support that, C++ was called, "C with Classes". If you need hardware control and are only an OOP geek, then you use C++, otherwise you use C.
Despite my answer, this question is childish and immature. If you need to know if a language is needed to be learnt of if you should use it, know its history! That will answer all of your questions. Just a friendly reminder, when I started to learn how to program in 2011, I heard C++ was fading away, Java is future, I also heard Windows Forms will die soon, and WPF is future. None of that happens and these news are caused by some idiots in computer science who have no idea what they are saying.
Quote: The creator of C++, Bjarne Stroustrup, has acknowledged that Simula 67 was the greatest influence on him to develop C++, to bring the kind of productivity enhancements offered by Simula to the raw computational speed offered by lower level languages like BCPL.
Simula - Wikipedia[^]
C++ - Wikipedia[^]
For more, Why I Created C++ | Big Think[^].
Sorry, if you find me rude.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Because C is the corner stone language in computing. It is the language of OSs, space ships, embedded, etc. C++ extends that power scales it, and is a true engineers language.
C# (Java) and other interpreted languages have their uses, principally where you want to limit the power of the language for security reasons, or to work at highly extrapolated levels a long way from the hardware.
|
|
|
|
|
As noted by others for drivers and embedded systems. It is a mature language that works well with hardware with less interpretation.
One reason many people left C++ was they hate pointers, but as those other languages mature, they too employ pointers, so in the end we are now seeing a revival of C++.
p.s.
Some people love pointers.
|
|
|
|
|
Does anyone have experience using Electric Cloud build accelerator with C++/CLI code?
I'm primarily interested to know if C++/CLI projects are supported. The Electric Cloud support/helpcenter returns no results for my related searches.
John
|
|
|
|
|
Almost every build automation tool supports the toolchains, or they provide tools to setup your own build tasks and set up your own binaries.
Do they allow that? I don't have an account, so I cannot test that.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
I have a complicated xml that i need to read into variables it looks like below example. I need to put each of those into attributes into a database then recreate the same xml with change attribute values from my database.
sample:
<wmi>
<wmifileheader fileid="123456.20060410.001714.909268" filetype="FOR" version="4.0.0">
<fh_to id="123456" name="Vendor name">
<fh_from id="2677" name="Walmart.com">
<fh_contact name="Walmart.com Operations Support" email="webops@walmart.com" phone="6508375465" phoneext="">
<wmiorderrequest>
<or_order requestnumber="66851611" ordernumber="2677127827645">
<or_dateplaced day="10" month="04" year="2006">
<or_shipping methodcode="MP" carriermethodcode="22" storenumber="" togethercode="SC">
<or_phone primary="6503555323" primaryext="" second="" secondext="">
<or_postal name="Steve Kelley" address1="112 Dry Creek Road" address2="" address3="" address4="" city="Pacifica" state="CA" postalcode="94044" country="USA">
<or_deliverydate day="14" month="04" year="2006">
<or_email>
<or_billing orderprice="45.38">
<or_payment method="MC-3951">
<or_phone primary="2096011006" primaryext="" second="" secondext="">
<or_postal name="John Furey" address1="1234 Main St" address2="" address3="" address4="" city="Stockton" state="CA" postalcode="95207" country="USA">
<or_email>john@email.com
<or_returns tcnumber="95675952991021084742" methodcode="RC">
<or_postal name=" " address1="" address2="" address3="" address4="" city="" state="" postalcode="" country="">
<or_permit number="" city="" state="" postalcode="">
<or_orderline linenumber="1" lineprice="45.38">
<or_item itemnumber="3866121" upc="2345678902376" sku="376" description="Yellow Phalaenopsis Orchid in Blue Ceramic Pot" quantity="1">
<or_price retail="29.97" tax="2.47" shipping="12.94">
<or_cost amount="21.00">
<or_lastdeliverymsg line1="0" line2="0" line3="0" line4="0">
<or_marketingmsg line1="0" line2="0" line3="0" line4="0">
<or_returnsmsg line1="0" line2="0" line3="0" line4="0">
|
|
|
|
|
Why have you posted this under Managed C++?
|
|
|
|
|
I am receiving a date structure in "24-9-2016 13:30" format. Now I want to convert time value to specific timezone, I am doing calculations and have number of hours to add or substract.
So I don't know: how can I initialize tm struct with the date value I have? how to add or substract hours in tc struct variable to get required date?
my intention is
Date received "24-9-2016 13:30" and 5 Hours to add so final Date: "24-9-2016 18:30"
time_t tempTime
time(&tempTime);
struct tm *initStruct = localtime(&tempTime);initStruct ->tm_year = 2016;
initStruct->tm_mon = 9;
initStruct->tm_hour = 13;
.
.
.
please provide inputs.
modified 24-Sep-16 4:55am.
|
|
|
|