<?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[Config auslesen und in Struktur schreiben]]></title><description><![CDATA[<p>Hi,<br />
ich habe an meinem aktuellen Projekt ein Problem.<br />
Ich habe eine config Datei (config.3dsim) welche folgendermassen aussieht:</p>
<pre><code class="language-cpp">[P1]
Masse = 1000
X = 100
Y = 0
Z = 0
VX = 0
VY = 0
VZ = 0
[P2]
Masse = 500
X = 0
Y = 0
Z = 0
VX = 0
VY = 0
VZ = 0
[P3]
Masse = 100
X = 0
Y = 0
Z = 0
VX = 0
VY = 0
VZ = 0
</code></pre>
<p>P1,P2,P3 sind die Strukturen in die ich dann die folgenden Werte einlesen will.<br />
Danach soll zum Beispiel in &quot;P1.m&quot; (Masse) 1000 stehen.</p>
<pre><code class="language-cpp">struct Satellite { 
	double xlenght; 
	double ylenght; 
	double zlenght; 
	double r; 
	double vx; 
	double vy; 
        double vz;
	double ax; 
	double ay; 
	double m;
}P1, P2, P3;
</code></pre>
<p>das ist noch die Struktur</p>
<p>Nun ich hoffe ihr könnt mir da etwas effektives Vorschlagen<br />
Gruss</p>
<p>Lukas</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/232683/config-auslesen-und-in-struktur-schreiben</link><generator>RSS for Node</generator><lastBuildDate>Fri, 25 Sep 2026 07:10:11 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/232683.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 25 Jan 2009 18:00:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Config auslesen und in Struktur schreiben on Sun, 25 Jan 2009 18:00:07 GMT]]></title><description><![CDATA[<p>Hi,<br />
ich habe an meinem aktuellen Projekt ein Problem.<br />
Ich habe eine config Datei (config.3dsim) welche folgendermassen aussieht:</p>
<pre><code class="language-cpp">[P1]
Masse = 1000
X = 100
Y = 0
Z = 0
VX = 0
VY = 0
VZ = 0
[P2]
Masse = 500
X = 0
Y = 0
Z = 0
VX = 0
VY = 0
VZ = 0
[P3]
Masse = 100
X = 0
Y = 0
Z = 0
VX = 0
VY = 0
VZ = 0
</code></pre>
<p>P1,P2,P3 sind die Strukturen in die ich dann die folgenden Werte einlesen will.<br />
Danach soll zum Beispiel in &quot;P1.m&quot; (Masse) 1000 stehen.</p>
<pre><code class="language-cpp">struct Satellite { 
	double xlenght; 
	double ylenght; 
	double zlenght; 
	double r; 
	double vx; 
	double vy; 
        double vz;
	double ax; 
	double ay; 
	double m;
}P1, P2, P3;
</code></pre>
<p>das ist noch die Struktur</p>
<p>Nun ich hoffe ihr könnt mir da etwas effektives Vorschlagen<br />
Gruss</p>
<p>Lukas</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1652165</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1652165</guid><dc:creator><![CDATA[Xbelt2]]></dc:creator><pubDate>Sun, 25 Jan 2009 18:00:07 GMT</pubDate></item><item><title><![CDATA[Reply to Config auslesen und in Struktur schreiben on Sun, 25 Jan 2009 18:12:57 GMT]]></title><description><![CDATA[<p>Um von Dateien zu lesen oder in sie zu schreiben, gibt es <code>std::fstream</code> . Mit <code>operator&gt;&gt;</code> kannst du einzelne Teile auslesen und in Variablen speichern.</p>
<p>Eine genauere Erklärung und Beispielcode findest du unter <a href="http://www.cplusplus.com" rel="nofollow">www.cplusplus.com</a>.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1652181</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1652181</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Sun, 25 Jan 2009 18:12:57 GMT</pubDate></item><item><title><![CDATA[Reply to Config auslesen und in Struktur schreiben on Sun, 25 Jan 2009 18:16:24 GMT]]></title><description><![CDATA[<p>Hallo Lukas,</p>
<p>ich unterstelle mal, dass X,Y und Z den Membern x-,y-,zlenght entsprechen. Dann sähe die Minimallösung so aus:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;limits&gt;

struct Satellite {
    double xlenght;
    double ylenght;
    double zlenght;
    double r;
    double vx;
    double vy;
        double vz;
    double ax;
    double ay;
    double m;
};

std::istream&amp; operator&gt;&gt;( std::istream&amp; in, Satellite&amp; sat )
{
    const std::streamsize ALL = std::numeric_limits&lt; std::streamsize &gt;::max();
    return ((((((in.ignore( ALL, '=' ) &gt;&gt; sat.m)
        .ignore( ALL, '=' ) &gt;&gt; sat.xlenght).ignore( ALL, '=' ) &gt;&gt; sat.ylenght).ignore( ALL, '=' ) &gt;&gt; sat.zlenght)
        .ignore( ALL, '=' ) &gt;&gt; sat.vx).ignore( ALL, '=' ) &gt;&gt; sat.vy).ignore( ALL, '=' ) &gt;&gt; sat.vz;
}

int main()
{
    using namespace std;
    ifstream file( &quot;input.txt&quot; );
    Satellite P1, P2, P3;
    if( file &gt;&gt; P1 &gt;&gt; P2 &gt;&gt; P3 )
        cout &lt;&lt; &quot;3 Satelliten gelesen &quot; &lt;&lt; endl;
    return 0;
}
</code></pre>
<p>Gruß<br />
Werner</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1652184</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1652184</guid><dc:creator><![CDATA[Werner Salomon]]></dc:creator><pubDate>Sun, 25 Jan 2009 18:16:24 GMT</pubDate></item><item><title><![CDATA[Reply to Config auslesen und in Struktur schreiben on Sun, 25 Jan 2009 18:56:39 GMT]]></title><description><![CDATA[<p>Herzliches Dankeschön<br />
Das funktioniert perfekt.<br />
Noch einen schönen Abend<br />
Gruss</p>
<p>Lukas</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1652213</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1652213</guid><dc:creator><![CDATA[Xbelt2]]></dc:creator><pubDate>Sun, 25 Jan 2009 18:56:39 GMT</pubDate></item></channel></rss>