<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>LeafLabs Garden &#187; Topic: how do I implement the String class?</title>
		<link>http://forums.leaflabs.com/topic.php?id=74322</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:17:55 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://forums.leaflabs.com/search.php</link>
		</textInput>
		<atom:link href="http://forums.leaflabs.com/rss.php?topic=74322" rel="self" type="application/rss+xml" />

		<item>
			<title>jstamour802 on "how do I implement the String class?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=74322#post-105393</link>
			<pubDate>Sun, 18 May 2014 08:52:16 +0000</pubDate>
			<dc:creator>jstamour802</dc:creator>
			<guid isPermaLink="false">105393@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;thanks a ton for your help - I was able to get everything to work. This put me over a major hump in a project I am working on.&#60;/p&#62;
&#60;p&#62;high five!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>ventosus on "how do I implement the String class?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=74322#post-105384</link>
			<pubDate>Mon, 12 May 2014 11:52:14 +0000</pubDate>
			<dc:creator>ventosus</dc:creator>
			<guid isPermaLink="false">105384@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;@jstamour802&#60;/p&#62;
&#60;p&#62;I put the 'extern &#34;C&#34;' there only to tell you that this is C code and may need adaptations to run in wirish/C++, and obviously you have found out exactly that ;-)&#60;/p&#62;
&#60;p&#62;So forget about the 'extern &#34;C&#34;.&#60;br /&#62;
IIRC, the right way to include C headers stdlib.h, string.h or stdio.h in C++ is:&#60;br /&#62;
#include &#38;lt;cstdlib&#38;gt;&#60;br /&#62;
#include &#38;lt;cstring&#38;gt;&#60;br /&#62;
#include &#38;lt;cstdio&#38;gt;&#60;/p&#62;
&#60;p&#62;I have actually tested both ways and they work fine here.&#60;br /&#62;
But I use the current launchpad GCC instead of the outdated codesourcery GCC...
&#60;/p&#62;</description>
		</item>
		<item>
			<title>jstamour802 on "how do I implement the String class?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=74322#post-105383</link>
			<pubDate>Mon, 12 May 2014 10:31:09 +0000</pubDate>
			<dc:creator>jstamour802</dc:creator>
			<guid isPermaLink="false">105383@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I was able to get &#38;lt;stdlib&#38;gt; to work, I had to add it at the top of my includes&#60;/p&#62;
&#60;p&#62;&#38;lt;stdlib&#38;gt;&#60;br /&#62;
...&#60;br /&#62;
&#38;lt;other includes&#38;gt;&#60;/p&#62;
&#60;p&#62;Otherwise it didnt work.&#60;/p&#62;
&#60;p&#62;The program compiles now, but now your first example doesn't work. It returns a blank value instead of the int. It worked for Arduino however.&#60;/p&#62;
&#60;p&#62;Also, I cant figure out where to put extern 'C' { without causing problems in my program. What exactly needs to be within the braces?&#60;/p&#62;
&#60;p&#62;Thanks in advance for any help.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>jstamour802 on "how do I implement the String class?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=74322#post-105382</link>
			<pubDate>Mon, 12 May 2014 08:26:46 +0000</pubDate>
			<dc:creator>jstamour802</dc:creator>
			<guid isPermaLink="false">105382@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Also If I try to include &#38;lt;stdlib.h&#38;gt; I get:&#60;/p&#62;
&#60;p&#62;\maple-ide-0.0.12-windowsxp32\hardware\tools\arm\bin\../lib/gcc/arm-none-eabi/4.4.1/../../../../arm-none-eabi/include/stdlib.h:72&#60;/p&#62;
&#60;p&#62;stdlib.h:72: error: expected unqualified-id before 'int'
&#60;/p&#62;</description>
		</item>
		<item>
			<title>jstamour802 on "how do I implement the String class?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=74322#post-105381</link>
			<pubDate>Mon, 12 May 2014 08:13:14 +0000</pubDate>
			<dc:creator>jstamour802</dc:creator>
			<guid isPermaLink="false">105381@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;ventosus - thank you for your answers. I tried the first example on Arduino and it works well.&#60;/p&#62;
&#60;p&#62;I then tried it on maple but I get 'atoi' not declared. How do I add 'atoi'? I found this from the FAQ: &#60;/p&#62;
&#60;p&#62;&#34;How can I use atoi()?&#60;br /&#62;
The CodeSourcery GCC compiler used to compile your programs is configured to link against the newlib C library, and allows the use of any of its headers.&#34;&#60;/p&#62;
&#60;p&#62;This doesn't tell me much...nor how to make it compile in my program. Is there another step I need to use 'atoi'?&#60;/p&#62;
&#60;p&#62;Also, I dont have 'String.h'. Where does this library come from?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>ventosus on "how do I implement the String class?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=74322#post-105378</link>
			<pubDate>Sun, 11 May 2014 16:26:27 +0000</pubDate>
			<dc:creator>ventosus</dc:creator>
			<guid isPermaLink="false">105378@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Or using sscanf...&#60;/p&#62;
&#60;p&#62;&#60;code&#62;&#60;br /&#62;
extern &#34;C&#34; {&#60;br /&#62;
#include &#38;lt;stdio.h&#38;gt;&#60;br /&#62;
	int pwn;&#60;br /&#62;
	sscanf(req, &#34;GET /ajax_inputs&#38;amp;PWM3=%i&#34;, &#38;amp;pwn);&#60;br /&#62;
	printf(&#34;%i\n&#34;, pwn);&#60;br /&#62;
}&#60;br /&#62;
&#60;/code&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>ventosus on "how do I implement the String class?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=74322#post-105376</link>
			<pubDate>Sun, 11 May 2014 13:41:50 +0000</pubDate>
			<dc:creator>ventosus</dc:creator>
			<guid isPermaLink="false">105376@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;This should be straight-forward with the C functions 'strstr' and 'atoi'.&#60;/p&#62;
&#60;p&#62;&#60;code&#62;&#60;br /&#62;
extern &#34;C&#34; {&#60;br /&#62;
#include &#38;lt;string.h&#38;gt;&#60;br /&#62;
#include &#38;lt;stdlib.h&#38;gt;&#60;/p&#62;
&#60;p&#62;char *req = &#34;GET /ajax_inputs&#38;amp;PWM3=1000&#38;amp;nocache=120749.0530796349&#34;;&#60;br /&#62;
char *ptr = strstr(req, &#34;PWM3=&#34;);&#60;br /&#62;
if(ptr)&#60;br /&#62;
{&#60;br /&#62;
     int pwn = atoi(ptr+5);&#60;br /&#62;
     // use pwn&#60;br /&#62;
}&#60;br /&#62;
}&#60;br /&#62;
&#60;/code&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>jstamour802 on "how do I implement the String class?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=74322#post-105374</link>
			<pubDate>Sun, 11 May 2014 08:57:57 +0000</pubDate>
			<dc:creator>jstamour802</dc:creator>
			<guid isPermaLink="false">105374@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;More specifically, I need to retrieve an integer from a string. I'm working on a web server interface that sends the value of a number field in a string like this:&#60;/p&#62;
&#60;p&#62;&#34;GET /ajax_inputs&#38;amp;PWM3=1000&#38;amp;nocache=120749.0530796349&#34;&#60;/p&#62;
&#60;p&#62;I need to extract the &#34;1000&#34; from &#34;PWM3=1000&#34; in the string, and use that value to write to a PWM pin.&#60;/p&#62;
&#60;p&#62;The string library in Arduino (or the standard C string library for that matter) can do it by the substring method, but is there a different way I can do it without the bloat of the string library?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>jstamour802 on "how do I implement the String class?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=74322#post-105365</link>
			<pubDate>Mon, 05 May 2014 09:04:03 +0000</pubDate>
			<dc:creator>jstamour802</dc:creator>
			<guid isPermaLink="false">105365@http://forums.leaflab