<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[kleines STRING - problem]]></title><description><![CDATA[<p>HALL0.</p>
<p>ich habe ein problem mit den STRINGS. mein code (liest eine datei aus und schreibt alles in eine neue datei) sieht so aus:</p>
<pre><code class="language-cpp">while (!datei.eof())
	{
        getline(datei,ZEILE);
		for (i=0;i&lt;(int)ZEILE.size();i++)
		{
			if (ZEILE[i] == '/') break;
			myfile &lt;&lt; ZEILE[i];
		}
		myfile &lt;&lt; &quot;\n&quot;;
	}
</code></pre>
<p>nehmen wir an, eine zeile meiner datei sieht wie folgt aus:</p>
<blockquote>
<p>1.1 2.3 43 /das sind die coordinaten</p>
</blockquote>
<p>nun möchte ich die 3 zahlen mittels 'ATOF' in double zahlen umwandeln, dazu muss ich aber den gesamten &quot;zeilenstring&quot; aufteilen in 4 einzelne strings (für die 3 zahlen und den text).<br />
wie könnte ich dies umsetzen?</p>
<p>VIELEN DANK.<br />
STICK.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/162402/kleines-string-problem</link><generator>RSS for Node</generator><lastBuildDate>Sat, 12 Sep 2026 04:44:12 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/162402.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 18 Oct 2006 09:07:52 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to kleines STRING - problem on Wed, 18 Oct 2006 09:07:52 GMT]]></title><description><![CDATA[<p>HALL0.</p>
<p>ich habe ein problem mit den STRINGS. mein code (liest eine datei aus und schreibt alles in eine neue datei) sieht so aus:</p>
<pre><code class="language-cpp">while (!datei.eof())
	{
        getline(datei,ZEILE);
		for (i=0;i&lt;(int)ZEILE.size();i++)
		{
			if (ZEILE[i] == '/') break;
			myfile &lt;&lt; ZEILE[i];
		}
		myfile &lt;&lt; &quot;\n&quot;;
	}
</code></pre>
<p>nehmen wir an, eine zeile meiner datei sieht wie folgt aus:</p>
<blockquote>
<p>1.1 2.3 43 /das sind die coordinaten</p>
</blockquote>
<p>nun möchte ich die 3 zahlen mittels 'ATOF' in double zahlen umwandeln, dazu muss ich aber den gesamten &quot;zeilenstring&quot; aufteilen in 4 einzelne strings (für die 3 zahlen und den text).<br />
wie könnte ich dies umsetzen?</p>
<p>VIELEN DANK.<br />
STICK.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1156858</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1156858</guid><dc:creator><![CDATA[stick_thai]]></dc:creator><pubDate>Wed, 18 Oct 2006 09:07:52 GMT</pubDate></item><item><title><![CDATA[Reply to kleines STRING - problem on Wed, 18 Oct 2006 09:12:26 GMT]]></title><description><![CDATA[<p>Am besten schaust du dir mal die FAQ zum Thema &quot;Einmal Zahl und zurück&quot; an - den Ansatz mit Stringstreams kannst du auch hier umsetzen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1156863</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1156863</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Wed, 18 Oct 2006 09:12:26 GMT</pubDate></item><item><title><![CDATA[Reply to kleines STRING - problem on Wed, 18 Oct 2006 09:18:18 GMT]]></title><description><![CDATA[<p>danke für die antwort. aber mein problem ist nicht die umwandlung von string in zahl, sondern das &quot;zerschneiden&quot; meines ganzen zeilenstrings in viele einzelne strings.</p>
<p>DANKE.<br />
STICK.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1156869</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1156869</guid><dc:creator><![CDATA[stick_thai]]></dc:creator><pubDate>Wed, 18 Oct 2006 09:18:18 GMT</pubDate></item><item><title><![CDATA[Reply to kleines STRING - problem on Wed, 18 Oct 2006 09:21:27 GMT]]></title><description><![CDATA[<p>Leerzeichen suchen und per substr() zerschneiden wäre ein Ansatz.</p>
<p>(wobei: aus einem stringstream kannst du auch mehrere Zahlen extrahieren - der liest jeweils bis zum nächsten Leerzeichen)</p>
<p>PS: Wenn du unbedingt C-Funktionen verwenden willst, nimm <a href="http://man.cx/strtod" rel="nofollow">man: strtod</a> und lass dir von der Funktion sagen, wo du beim nächsten Durchlauf weiterrechnen mußt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1156871</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1156871</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Wed, 18 Oct 2006 09:21:27 GMT</pubDate></item><item><title><![CDATA[Reply to kleines STRING - problem on Wed, 18 Oct 2006 09:31:38 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;fstream&gt;
using namespace std;

int main()
{
	ifstream in;
	string row = &quot;&quot;;

	in.open(&quot;foo.txt&quot;);
	while(in&gt;&gt;row)
	{
		if(row.substr(0,1)!=&quot;/&quot;)
			cout &lt;&lt; row &lt;&lt; endl;
	}
	in.close();

	getchar();
	return 0;
}
</code></pre>
<p>Mit in&gt;&gt;row werden hier Leerzeichen automatisch als Wertentrenner interpretiert. Somit erhälst du alle Werte einzeln, selbst wenn sie nebeneinander in einer Zeile stehen.<br />
Dann musst du nur noch den Kommentar ausfiltern (siehe Code), die Zeichenketten umwandeln (selber machen) und in Datei abspeichern (selber machen).</p>
<p>Getestet mit foo.txt:</p>
<pre><code>2.5 3.66 10.0
4.8 5.00 12.0 /Kommentar
12.10 12.00
</code></pre>
<p>Hoffe, das hilft <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1156890</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1156890</guid><dc:creator><![CDATA[marco.b]]></dc:creator><pubDate>Wed, 18 Oct 2006 09:31:38 GMT</pubDate></item><item><title><![CDATA[Reply to kleines STRING - problem on Wed, 18 Oct 2006 10:21:23 GMT]]></title><description><![CDATA[<p>DANKE, mit 'substr' hat es funktioniert!</p>
<p>STICK.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1156942</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1156942</guid><dc:creator><![CDATA[stick_thai]]></dc:creator><pubDate>Wed, 18 Oct 2006 10:21:23 GMT</pubDate></item></channel></rss>