<?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[Struct aus List ausgeben]]></title><description><![CDATA[<p>Hi,</p>
<p>ich möchte aus einer Textdatei zeilenweise einlesen und den Inhalt in eine Struct mittels memcpy kopieren. Diese Struct soll danach in eine List geschoben werden. Ich hänge bei der Ausgabe der Elemente. Soll ich eine Funktion schreiben, so wie unten angegeben? Wenn ja, rufe ich die einzelnen Elemente nacheinander auf? Irgendwie muss man das ja noch mit einem pop_back kombinieren?</p>
<p>Momentan siehts so aus:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;string&gt;
#include &lt;list&gt;

using namespace std;

// Structure
struct pattern
{
	int mtrkl[6];
	string str[7];
	int id[2];
};  

ostream&amp; output(ostream &amp;out, pattern &amp;data)
{
	out &lt;&lt; &quot; matrkl:&quot; &lt;&lt; data.mtrkl &lt;&lt; &quot; str:&quot; &lt;&lt; data.str 
	&lt;&lt; &quot; id:&quot; &lt;&lt; data.id &lt;&lt; endl;
	return out;  
}

int main()
{
	// Filename
	string filename;
	cout &lt;&lt; &quot;Path/Filename of the Input File: &quot; &lt;&lt; endl;
	cin &gt;&gt; filename;

	// Open file
	ifstream ifile;
	ifile.open(filename.c_str(), ios_base::in);
	if(!ifile)
	{
		cout &lt;&lt; &quot;Error at opening File.&quot; &lt;&lt; endl;
		return -1;
	}

	// Read input file
	list&lt;pattern&gt; pat_lst;
	pattern mypat;

	string reader;

	while(getline(ifile, reader))
	{
		memcpy(&amp;mypat, reader.c_str(), 15);
		pat_lst.push_back(mypat);	
	}	 

	while(!pat_lst.empty())
	{

	}

return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/208236/struct-aus-list-ausgeben</link><generator>RSS for Node</generator><lastBuildDate>Sun, 11 Oct 2026 13:44:33 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/208236.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 16 Mar 2008 17:16:56 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Struct aus List ausgeben on Sun, 16 Mar 2008 17:16:56 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>ich möchte aus einer Textdatei zeilenweise einlesen und den Inhalt in eine Struct mittels memcpy kopieren. Diese Struct soll danach in eine List geschoben werden. Ich hänge bei der Ausgabe der Elemente. Soll ich eine Funktion schreiben, so wie unten angegeben? Wenn ja, rufe ich die einzelnen Elemente nacheinander auf? Irgendwie muss man das ja noch mit einem pop_back kombinieren?</p>
<p>Momentan siehts so aus:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;string&gt;
#include &lt;list&gt;

using namespace std;

// Structure
struct pattern
{
	int mtrkl[6];
	string str[7];
	int id[2];
};  

ostream&amp; output(ostream &amp;out, pattern &amp;data)
{
	out &lt;&lt; &quot; matrkl:&quot; &lt;&lt; data.mtrkl &lt;&lt; &quot; str:&quot; &lt;&lt; data.str 
	&lt;&lt; &quot; id:&quot; &lt;&lt; data.id &lt;&lt; endl;
	return out;  
}

int main()
{
	// Filename
	string filename;
	cout &lt;&lt; &quot;Path/Filename of the Input File: &quot; &lt;&lt; endl;
	cin &gt;&gt; filename;

	// Open file
	ifstream ifile;
	ifile.open(filename.c_str(), ios_base::in);
	if(!ifile)
	{
		cout &lt;&lt; &quot;Error at opening File.&quot; &lt;&lt; endl;
		return -1;
	}

	// Read input file
	list&lt;pattern&gt; pat_lst;
	pattern mypat;

	string reader;

	while(getline(ifile, reader))
	{
		memcpy(&amp;mypat, reader.c_str(), 15);
		pat_lst.push_back(mypat);	
	}	 

	while(!pat_lst.empty())
	{

	}

return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1475356</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1475356</guid><dc:creator><![CDATA[conUW]]></dc:creator><pubDate>Sun, 16 Mar 2008 17:16:56 GMT</pubDate></item><item><title><![CDATA[Reply to Struct aus List ausgeben on Sun, 16 Mar 2008 19:13:23 GMT]]></title><description><![CDATA[<p>Wenn du das schon mit den Streams ausgibst würde ich eher</p>
<p>ostream&amp; operator&lt;&lt;(ostream &amp;out, pattern &amp;data);</p>
<p>überladen als eine funktion zu schreiben <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1475447</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1475447</guid><dc:creator><![CDATA[darthdespotism]]></dc:creator><pubDate>Sun, 16 Mar 2008 19:13:23 GMT</pubDate></item><item><title><![CDATA[Reply to Struct aus List ausgeben on Sun, 16 Mar 2008 19:33:58 GMT]]></title><description><![CDATA[<p>Ja danke, das ist wirklich besser.<br />
Die Struct-Elemente sind ja Arrays. Wie kann ich die richtig ausgeben?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1475458</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1475458</guid><dc:creator><![CDATA[conUW]]></dc:creator><pubDate>Sun, 16 Mar 2008 19:33:58 GMT</pubDate></item><item><title><![CDATA[Reply to Struct aus List ausgeben on Sun, 16 Mar 2008 19:58:56 GMT]]></title><description><![CDATA[<p>mit einer Schleife oder std::for_each() würde ich mal sagen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1475473</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1475473</guid><dc:creator><![CDATA[darthdespotism]]></dc:creator><pubDate>Sun, 16 Mar 2008 19:58:56 GMT</pubDate></item><item><title><![CDATA[Reply to Struct aus List ausgeben on Sun, 16 Mar 2008 20:17:49 GMT]]></title><description><![CDATA[<p>Und wie genau sammle ich die Werte auf? Folgendes z.B geht nicht. Bei den int Arrays ist es ähnlich problematisch.</p>
<pre><code class="language-cpp">string tmp_str(&quot;&quot;);

	for(int i(0); i &lt; 7; ++i)	tmp_str += data.str[i];
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1475483</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1475483</guid><dc:creator><![CDATA[conUW]]></dc:creator><pubDate>Sun, 16 Mar 2008 20:17:49 GMT</pubDate></item></channel></rss>