user80747: Pardon me, I am a novice programmer. I was trying to use the toInt() function for a std::string but I noticed that toInt() only works for the String class. So, I have an std::string sliderValue and wanted to convert it to the String class so I could use the toInt() function. Here, I found a way that seemed to pacify Intellisense, vMicro, and building. I did:
String convertValue = strcpy(new char[sliderValue.length() + 1], sliderValue.c_str());

so I could do:
ledcWrite(ledChannel, convertValue.toInt()  * (10.24));

Is there a better way to do this or am I on point? Also, I'd love to get insight in what I'm doing, if possible. Thanks folks!
P.S. I looked up this here at arduino stackexchange, and it didn't seem to provide a solution specific to my question.

user4143: There is absolutely no need to use String (for anything, generally...). Instead you can either (if you have it) use std::stoi() or use strtol() on the c_str of the string.
ledcWrite(ledChannel, std::stoi(sliderValue)  * (10.24));

Or
ledcWrite(ledChannel, strtol(sliderValue.c_str(), NULL, 10)  * (10.24));

The former just converts into the latter anyway.

80747: <p>Pardon me, I am a novice programmer. I was trying to use the toInt() function for a std::string but I noticed that toInt() only works for the String class. So, I have an std::string sliderValue and wanted to convert it to the String class so I could use the toInt() function. <a href="https://www.techiedelight.com/convert-std-string-char-cpp/" rel="nofollow noreferrer">Here</a>, I found a way that seemed to pacify Intellisense, vMicro, and building. I did:</p>
<pre><code>String convertValue = strcpy(new char[sliderValue.length() + 1], sliderValue.c_str());
</code></pre>
<p>so I could do:</p>
<pre><code>ledcWrite(ledChannel, convertValue.toInt()  * (10.24));
</code></pre>
<p>Is there a better way to do this or am I on point? Also, I'd love to get insight in what I'm doing, if possible. Thanks folks!</p>
<p>P.S. I looked up <a href="https://arduino.stackexchange.com/questions/56365/arduino-convert-stdstring-to-string">this</a> here at arduino stackexchange, and it didn't seem to provide a solution specific to my question.</p>
 4143: <p>There is absolutely no need to use <code>String</code> (for anything, generally...). Instead you can either (if you have it) use <code>std::stoi()</code> or use <code>strtol()</code> on the <code>c_str</code> of the string.</p>
<pre class="lang-cpp prettyprint-override"><code>ledcWrite(ledChannel, std::stoi(sliderValue)  * (10.24));
</code></pre>
<p>Or</p>
<pre class="lang-cpp prettyprint-override"><code>ledcWrite(ledChannel, strtol(sliderValue.c_str(), NULL, 10)  * (10.24));
</code></pre>
<p>The former just converts into the latter anyway.</p>
