<?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[Tabellen auslesen]]></title><description><![CDATA[<p>hallo,</p>
<p>ich muss eine Tabelle auslesen. in welchem Datentyp ist es günstig, eine solche Tabelle zu speichern...<br />
Ich dachte an einen map&lt;char,map&lt;char,int&gt; &gt; doch komm ich damit momentan noch nicht klar!</p>
<p>Die Tabellen sehen ungefähr so aus und ich muss auf die einzelnen Werte zugreifen (z.B Q|R =&gt; 1). Jeder Buchstabe kommt dabei einmal in der hozizontalen und einmal in der vertikalen vor!</p>
<p>A R N D C Q E G H I<br />
A 4 -1 -2 -2 0 -1 -1 0 -2 -1<br />
R -1 5 0 -2 -3 1 0 -2 0 -3</p>
<p>thx4help</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/130903/tabellen-auslesen</link><generator>RSS for Node</generator><lastBuildDate>Thu, 27 Aug 2026 05:02:19 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/130903.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 28 Dec 2005 16:51:03 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Tabellen auslesen on Wed, 28 Dec 2005 16:51:03 GMT]]></title><description><![CDATA[<p>hallo,</p>
<p>ich muss eine Tabelle auslesen. in welchem Datentyp ist es günstig, eine solche Tabelle zu speichern...<br />
Ich dachte an einen map&lt;char,map&lt;char,int&gt; &gt; doch komm ich damit momentan noch nicht klar!</p>
<p>Die Tabellen sehen ungefähr so aus und ich muss auf die einzelnen Werte zugreifen (z.B Q|R =&gt; 1). Jeder Buchstabe kommt dabei einmal in der hozizontalen und einmal in der vertikalen vor!</p>
<p>A R N D C Q E G H I<br />
A 4 -1 -2 -2 0 -1 -1 0 -2 -1<br />
R -1 5 0 -2 -3 1 0 -2 0 -3</p>
<p>thx4help</p>
]]></description><link>https://www.c-plusplus.net/forum/post/951563</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/951563</guid><dc:creator><![CDATA[K.A.]]></dc:creator><pubDate>Wed, 28 Dec 2005 16:51:03 GMT</pubDate></item><item><title><![CDATA[Reply to Tabellen auslesen on Wed, 28 Dec 2005 16:55:57 GMT]]></title><description><![CDATA[<p>Ich weiss zwar nicht genau was du damit tun willst, aber wie wärs denn mit:<br />
map&lt;pair&lt;char, char&gt;, int&gt;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/951565</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/951565</guid><dc:creator><![CDATA[Redhead]]></dc:creator><pubDate>Wed, 28 Dec 2005 16:55:57 GMT</pubDate></item><item><title><![CDATA[Reply to Tabellen auslesen on Wed, 28 Dec 2005 20:54:53 GMT]]></title><description><![CDATA[<p>wie kann ich beim einlesen von dateien(hier tabellen) ein end-of-line abfragen. Ich &quot;bräuchte&quot; eine Abfrage ähnlich wie eof =&gt; end-of-file...</p>
<p>^^</p>
<p>thx</p>
]]></description><link>https://www.c-plusplus.net/forum/post/951773</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/951773</guid><dc:creator><![CDATA[K.A.]]></dc:creator><pubDate>Wed, 28 Dec 2005 20:54:53 GMT</pubDate></item><item><title><![CDATA[Reply to Tabellen auslesen on Wed, 28 Dec 2005 22:27:39 GMT]]></title><description><![CDATA[<p>K.A. schrieb:</p>
<blockquote>
<p>wie kann ich beim einlesen von dateien(hier tabellen) ein end-of-line abfragen. Ich &quot;bräuchte&quot; eine Abfrage ähnlich wie eof =&gt; end-of-file...</p>
<p>^^</p>
<p>thx</p>
</blockquote>
<p>getline()<br />
oder einfach auf das &quot;\n&quot; zeichen prüfen, denn das ist das zeichen für zeilenumbruch.</p>
<p>mfg.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/951825</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/951825</guid><dc:creator><![CDATA[joomoo]]></dc:creator><pubDate>Wed, 28 Dec 2005 22:27:39 GMT</pubDate></item><item><title><![CDATA[Reply to Tabellen auslesen on Wed, 04 Jan 2006 11:49:20 GMT]]></title><description><![CDATA[<p>Hallo,<br />
mit Hilfe unten angegebenen Funktion, werden Daten aus Excel eingelesen.<br />
Ich schaffe es leider nicht die zu verarbeiten. Kann mir jemand Bitte helfen.</p>
<p>void load ( void )<br />
{<br />
SQLHENV hEnv = 0;<br />
SQLHDBC hDBC = 0;<br />
SQLHSTMT hStmt = 0;<br />
SQLCHAR szConnStr[255];<br />
SQLCHAR szStmt[255];<br />
SQLCHAR szSem[255];<br />
SWORD cbConnStr;<br />
RETCODE rc;<br />
SDWORD sdwSMLen;<br />
SDWORD sdwDZLen;<br />
SDWORD sdwBZLen;<br />
SDWORD sdwVLen;<br />
SDWORD sdwULen;<br />
int i;<br />
char szResult[1000];</p>
<p>SQLTRY(&quot;SQLAllocEnv&quot;, SQLAllocEnv(&amp;hEnv))<br />
SQLTRY(&quot;SQLAllocConnect&quot;, SQLAllocConnect(hEnv, &amp;hDBC))<br />
SQLTRY(&quot;SQLDriverConnect&quot;, SQLDriverConnect(hDBC, NULL, CONNSTR, CONNLEN, szConnStr, sizeof(szConnStr), &amp;cbConnStr, SQL_DRIVER_NOPROMPT))<br />
SQLTRY(&quot;SQLAllocStmt&quot;, SQLAllocStmt(hDBC, &amp;hStmt))</p>
<p>sprintf(szStmt, &quot;SELECT * FROM [Tabelle1$]&quot;);<br />
SQLTRY(&quot;SQLPrepare&quot;, SQLPrepare(hStmt, szStmt, strlen(szStmt)))</p>
<p>SQLTRY(&quot;SQLBindCol&quot;, SQLBindCol(hStmt, 1, SQL_C_CHAR, (PTR)szSem, sizeof(szSemester), &amp;sdwSMLen))</p>
<p>SQLTRY(&quot;SQLExecute&quot;, SQLExecute(hStmt))</p>
<p>for (i = 1; (rc = SQLFetch(hStmt)) == SQL_SUCCESS; i++)<br />
{</p>
<p>printf(&quot;#%d\t %s\n&quot;, i, szSem );</p>
<p>}</p>
<p>if (rc != SQL_NO_DATA_FOUND)<br />
{<br />
SQLTRY(&quot;SQLFetch&quot;, rc)<br />
}</p>
<p>printf(&quot;Operation war erfolgreich.\n&quot;);</p>
<p>if (hStmt) SQLFreeStmt(hStmt, SQL_CLOSE);<br />
if (hDBC) SQLDisconnect(hDBC);<br />
if (hDBC) SQLFreeConnect(hDBC);<br />
if (hEnv) SQLFreeEnv(hEnv);<br />
}</p>
<p>mfg Gast</p>
]]></description><link>https://www.c-plusplus.net/forum/post/956473</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/956473</guid><dc:creator><![CDATA[Gast6]]></dc:creator><pubDate>Wed, 04 Jan 2006 11:49:20 GMT</pubDate></item><item><title><![CDATA[Reply to Tabellen auslesen on Wed, 04 Jan 2006 19:03:11 GMT]]></title><description><![CDATA[<p>K.A. schrieb:</p>
<blockquote>
<p>ich muss eine Tabelle auslesen. in welchem Datentyp ist es günstig, eine solche Tabelle zu speichern...<br />
Ich dachte an einen map&lt;char,map&lt;char,int&gt; &gt; doch komm ich damit momentan noch nicht klar!</p>
</blockquote>
<p>am besten Du machst Dir eine eigene Klasse mit einer map&lt;pair&lt;char, char&gt;, int&gt; im Bauch, wie schon von Redhead vorgeschlagen.<br />
Eine Klasse - ich nenne sie mal Tabelle - sollte einen istream-operator haben und vielleicht gleich eine Methode um einfach mit zwei Zeichen an die Werte der Tabelle ranzukommen.</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;map&gt;

class Tabelle
{
public:
    Tabelle() : m_tab() {}
    int&amp; operator()( char c1, char c2 );
    friend std::istream&amp; operator&gt;&gt;( std::istream&amp; in, Tabelle&amp; tab_ );
private:
    std::map&lt; std::pair&lt; char, char &gt;, int &gt; m_tab;
};
</code></pre>
<p>Die Implementierung sähe dann so aus</p>
<pre><code class="language-cpp">#include &lt;iterator&gt;
#include &lt;string&gt;
#include &lt;sstream&gt;
#include &lt;vector&gt;

    int&amp; Tabelle::operator()( char c1, char c2 )
    {
        return m_tab[ std::make_pair( c1, c2 ) ];
    }

    std::istream&amp; operator&gt;&gt;( std::istream&amp; in, Tabelle&amp; tab_ )
    {
        Tabelle tab;
        std::vector&lt; char &gt; lbl2;   // Labels der Horizontalen (Kopfzeile)
        {   // --   Kopfzeile einlesen
            std::string zl1str;
            if( !std::getline( in, zl1str ) ) 
                return in;
            std::stringstream zl1( zl1str );
            std::copy( std::istream_iterator&lt; char &gt;( zl1 ), std::istream_iterator&lt; char &gt;(),
                std::back_inserter( lbl2 ) );
        }
        for( int zl=0; zl&lt;lbl2.size(); ++zl )
        {
            char lbl1;
            if( (in &gt;&gt; lbl1).fail() )   // ersten Buchstaben der Zeile lesen
                return in;
            for( int sp=0; sp&lt;lbl2.size(); ++sp )
            {
                int zahl;
                if( (in &gt;&gt; zahl).fail() )   // Zahl in der Tabelle einlesen ..
                    return in;
                tab.m_tab.insert( std::make_pair( // .. und speichern
                    std::make_pair( lbl1, lbl2[sp] ),   // &lt;- Key
                    zahl ) );                           // &lt;- Value
            }
        }
        tab.m_tab.swap( tab_.m_tab );   // alles Ok, dann Tabelle übernehmen
        return in;
    }
</code></pre>
<p>und die Anwendung wird ganz einfach</p>
<pre><code class="language-cpp">#include &lt;fstream&gt;
#include &lt;iostream&gt;

int main()
{
    using namespace std;
    Tabelle tab;
    ifstream file(&quot;input.txt&quot;);
    if( file &gt;&gt; tab )
    {
        cout &lt;&lt; &quot;Zahl an Position(I,H) ist &quot; &lt;&lt; tab( 'I', 'H' ) &lt;&lt; endl;
        cout &lt;&lt; &quot;Zahl an Position(N,G) ist &quot; &lt;&lt; tab( 'N', 'G' ) &lt;&lt; endl;
    }
    return 0;
}
</code></pre>
<p>Gruß<br />
Werner</p>
]]></description><link>https://www.c-plusplus.net/forum/post/957019</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/957019</guid><dc:creator><![CDATA[Werner Salomon]]></dc:creator><pubDate>Wed, 04 Jan 2006 19:03:11 GMT</pubDate></item></channel></rss>