<?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[Schach - Pointer zum String]]></title><description><![CDATA[<p>Bisher funktioniert mein Programm recht gut,<br />
funktionen:<br />
Schachfeld mit Figuren anzeigen<br />
Problem:<br />
nächste Funktion die erstellt werden soll = Bewegung des Bauern;<br />
ansich hat das schon funktioniert, nur da ich die schleife die dafür zuständig ist in eine außenstehende Funktion einpacken wollte, kam ich auf das Problem.<br />
Das Programm läuft bis auf eine Stelle:</p>
<p><strong>einen Pointer des std::string xy[][] in die Funktion zu übertragen</strong></p>
<p>andere Probleme und Unvollständigkeiten sollen nicht beachtet werden.<br />
Danke</p>
<pre><code>//
//  main.cpp
//  Schach
//
//  Created by Benno Dörr on 09.04.14.
//  Copyright (c) 2014 Benno Dörr. All rights reserved.
//

#include &lt;iostream&gt;
#include &lt;string&gt;

void tout(std::string xy[9][9]);
void action(int *yfig, int *xfig, int *turnfig, int xheap, int yheap, std::string *xy[9][9]);

int main()
{
    std::string xy[9][9];
    std::string figwahl;

    for (int i = 8; i&gt;0; --i) {
        for (int y = 0; y&lt;8; ++y) {
            xy[i][y] = &quot;_   &quot;;
        }
    }

//  =============================================================================
//  =============================================================================
//                              Figure Creation
//  =============================================================================
//  =============================================================================
    struct fig {
        int x = 0, y = 0, turn = 0;
    };

    fig wBauer1, wBauer2, wBauer3, wBauer4, wBauer5, wBauer6, wBauer7, wBauer8;
    wBauer1.x = 1; wBauer1.y = 2; xy[wBauer1.y][wBauer1.x-1] = &quot;wB1 &quot;;
    wBauer2.x = 2; wBauer2.y = 2; xy[wBauer2.y][wBauer2.x-1] = &quot;wB2 &quot;;
    wBauer3.x = 3; wBauer3.y = 2; xy[wBauer3.y][wBauer3.x-1] = &quot;wB3 &quot;;
    wBauer4.x = 4; wBauer4.y = 2; xy[wBauer4.y][wBauer4.x-1] = &quot;wB4 &quot;;
    wBauer5.x = 5; wBauer5.y = 2; xy[wBauer5.y][wBauer5.x-1] = &quot;wB5 &quot;;
    wBauer6.x = 6; wBauer6.y = 2; xy[wBauer6.y][wBauer6.x-1] = &quot;wB6 &quot;;
    wBauer7.x = 7; wBauer7.y = 2; xy[wBauer7.y][wBauer7.x-1] = &quot;wB7 &quot;;
    wBauer8.x = 8; wBauer8.y = 2; xy[wBauer8.y][wBauer8.x-1] = &quot;wB8 &quot;;

    fig wDame, wKing, wlTurm, wrTurm, wlSpring, wrSpring, wlLauf, wrLauf, heap;
    wDame.x = 4; wDame.y = 1; xy[wDame.y][wDame.x-1] = &quot;wDa &quot;;
    wKing.x = 5; wKing.y = 1; xy[wKing.y][wKing.x-1] = &quot;wKi &quot;;
    wlTurm.x = 1; wlTurm.y = 1; xy[wlTurm.y][wlTurm.x-1] = &quot;wlT &quot;;
    wrTurm.x = 8; wrTurm.y = 1; xy[wrTurm.y][wrTurm.x-1] = &quot;wrT &quot;;
    wlSpring.x = 2; wlSpring.y = 1; xy[wlSpring.y][wlSpring.x-1] = &quot;wlS &quot;;
    wrSpring.x = 7; wrSpring.y = 1; xy[wrSpring.y][wrSpring.x-1] = &quot;wrS &quot;;
    wlLauf.x = 3; wlLauf.y = 1; xy[wlLauf.y][wlLauf.x-1] = &quot;wlL &quot;;
    wrLauf.x = 6; wrLauf.y = 1; xy[wrLauf.y][wrLauf.x-1] = &quot;wrL &quot;;

//  =============================================================================
//  =============================================================================

    tout(xy);
    std::cout &lt;&lt; &quot;Welche Figur soll bewegt werden? &quot;;
    std::cin &gt;&gt; figwahl;
    if (figwahl == &quot;wb1&quot;||&quot;wB1&quot;) {
        action(&amp;wBauer1.y, &amp;wBauer1.x, &amp;wBauer1.turn, heap.x, heap.y, &amp;xy);
    }

    tout(xy);
}

void tout(std::string xy[9][9])
{
    std::cout &lt;&lt; &quot;  1   2   3   4   5   6   7   8\n&quot;;
    for (int i = 8; i&gt;0; --i) {
        for (int y = 0; y&lt;8; ++y) {
            if (y == 0) {
                switch (i) {
                    case 1:
                        std::cout &lt;&lt; &quot;A &quot;;
                        break;
                    case 2:
                        std::cout &lt;&lt; &quot;B &quot;;
                        break;
                    case 3:
                        std::cout &lt;&lt; &quot;C &quot;;
                        break;
                    case 4:
                        std::cout &lt;&lt; &quot;D &quot;;
                        break;
                    case 5:
                        std::cout &lt;&lt; &quot;E &quot;;
                        break;
                    case 6:
                        std::cout &lt;&lt; &quot;F &quot;;
                        break;
                    case 7:
                        std::cout &lt;&lt; &quot;G &quot;;
                        break;
                    case 8:
                        std::cout &lt;&lt; &quot;H &quot;;
                        break;

                    default:
                        break;
                }

            }
            std::cout &lt;&lt; xy[i][y];
        }
        std::cout &lt;&lt; std::endl;
    }
    std::cout &lt;&lt; std::endl;
}

void action(int *yfig, int *xfig, int *turnfig, int xheap, int yheap, std::string *xy[9][9])
{
    int mov1 = 0, mov2 = 0, mov3 = 0;
    int act = 0;

    std::cout &lt;&lt; &quot;Bewegen oder Schlagen? &quot;;
    std::cin &gt;&gt; act;
    switch (act) {
        case 1:
            switch (*turnfig) {
                case 0:
                    std::cout &lt;&lt; &quot;1 oder 2 Felder bewegen? &quot;;
                    std::cin &gt;&gt; mov1;
                    switch (mov1) {
                        case 1:
                            xheap = *xfig;
                            yheap = *yfig;
                            *yfig = *yfig+1;

                            *xy[yheap][xheap-1] = &quot;_   &quot;;
                            *xy[*yfig][*xfig-1] = &quot;wB1 &quot;;

                            break;
                        default:
                            xheap = *xfig;
                            yheap = *yfig;
                            *yfig = *yfig+2;

                            *xy[yheap][xheap-1] = &quot;_   &quot;;
                            *xy[*yfig][*xfig-1] = &quot;wB1 &quot;;
                            break;
                    }
                    break;
                case !0:

                    break;
            }
            break;
        case !1:

            break;
    }
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/325090/schach-pointer-zum-string</link><generator>RSS for Node</generator><lastBuildDate>Mon, 13 Jul 2026 11:10:59 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/325090.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 14 Apr 2014 09:18:38 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Schach - Pointer zum String on Mon, 14 Apr 2014 09:18:38 GMT]]></title><description><![CDATA[<p>Bisher funktioniert mein Programm recht gut,<br />
funktionen:<br />
Schachfeld mit Figuren anzeigen<br />
Problem:<br />
nächste Funktion die erstellt werden soll = Bewegung des Bauern;<br />
ansich hat das schon funktioniert, nur da ich die schleife die dafür zuständig ist in eine außenstehende Funktion einpacken wollte, kam ich auf das Problem.<br />
Das Programm läuft bis auf eine Stelle:</p>
<p><strong>einen Pointer des std::string xy[][] in die Funktion zu übertragen</strong></p>
<p>andere Probleme und Unvollständigkeiten sollen nicht beachtet werden.<br />
Danke</p>
<pre><code>//
//  main.cpp
//  Schach
//
//  Created by Benno Dörr on 09.04.14.
//  Copyright (c) 2014 Benno Dörr. All rights reserved.
//

#include &lt;iostream&gt;
#include &lt;string&gt;

void tout(std::string xy[9][9]);
void action(int *yfig, int *xfig, int *turnfig, int xheap, int yheap, std::string *xy[9][9]);

int main()
{
    std::string xy[9][9];
    std::string figwahl;

    for (int i = 8; i&gt;0; --i) {
        for (int y = 0; y&lt;8; ++y) {
            xy[i][y] = &quot;_   &quot;;
        }
    }

//  =============================================================================
//  =============================================================================
//                              Figure Creation
//  =============================================================================
//  =============================================================================
    struct fig {
        int x = 0, y = 0, turn = 0;
    };

    fig wBauer1, wBauer2, wBauer3, wBauer4, wBauer5, wBauer6, wBauer7, wBauer8;
    wBauer1.x = 1; wBauer1.y = 2; xy[wBauer1.y][wBauer1.x-1] = &quot;wB1 &quot;;
    wBauer2.x = 2; wBauer2.y = 2; xy[wBauer2.y][wBauer2.x-1] = &quot;wB2 &quot;;
    wBauer3.x = 3; wBauer3.y = 2; xy[wBauer3.y][wBauer3.x-1] = &quot;wB3 &quot;;
    wBauer4.x = 4; wBauer4.y = 2; xy[wBauer4.y][wBauer4.x-1] = &quot;wB4 &quot;;
    wBauer5.x = 5; wBauer5.y = 2; xy[wBauer5.y][wBauer5.x-1] = &quot;wB5 &quot;;
    wBauer6.x = 6; wBauer6.y = 2; xy[wBauer6.y][wBauer6.x-1] = &quot;wB6 &quot;;
    wBauer7.x = 7; wBauer7.y = 2; xy[wBauer7.y][wBauer7.x-1] = &quot;wB7 &quot;;
    wBauer8.x = 8; wBauer8.y = 2; xy[wBauer8.y][wBauer8.x-1] = &quot;wB8 &quot;;

    fig wDame, wKing, wlTurm, wrTurm, wlSpring, wrSpring, wlLauf, wrLauf, heap;
    wDame.x = 4; wDame.y = 1; xy[wDame.y][wDame.x-1] = &quot;wDa &quot;;
    wKing.x = 5; wKing.y = 1; xy[wKing.y][wKing.x-1] = &quot;wKi &quot;;
    wlTurm.x = 1; wlTurm.y = 1; xy[wlTurm.y][wlTurm.x-1] = &quot;wlT &quot;;
    wrTurm.x = 8; wrTurm.y = 1; xy[wrTurm.y][wrTurm.x-1] = &quot;wrT &quot;;
    wlSpring.x = 2; wlSpring.y = 1; xy[wlSpring.y][wlSpring.x-1] = &quot;wlS &quot;;
    wrSpring.x = 7; wrSpring.y = 1; xy[wrSpring.y][wrSpring.x-1] = &quot;wrS &quot;;
    wlLauf.x = 3; wlLauf.y = 1; xy[wlLauf.y][wlLauf.x-1] = &quot;wlL &quot;;
    wrLauf.x = 6; wrLauf.y = 1; xy[wrLauf.y][wrLauf.x-1] = &quot;wrL &quot;;

//  =============================================================================
//  =============================================================================

    tout(xy);
    std::cout &lt;&lt; &quot;Welche Figur soll bewegt werden? &quot;;
    std::cin &gt;&gt; figwahl;
    if (figwahl == &quot;wb1&quot;||&quot;wB1&quot;) {
        action(&amp;wBauer1.y, &amp;wBauer1.x, &amp;wBauer1.turn, heap.x, heap.y, &amp;xy);
    }

    tout(xy);
}

void tout(std::string xy[9][9])
{
    std::cout &lt;&lt; &quot;  1   2   3   4   5   6   7   8\n&quot;;
    for (int i = 8; i&gt;0; --i) {
        for (int y = 0; y&lt;8; ++y) {
            if (y == 0) {
                switch (i) {
                    case 1:
                        std::cout &lt;&lt; &quot;A &quot;;
                        break;
                    case 2:
                        std::cout &lt;&lt; &quot;B &quot;;
                        break;
                    case 3:
                        std::cout &lt;&lt; &quot;C &quot;;
                        break;
                    case 4:
                        std::cout &lt;&lt; &quot;D &quot;;
                        break;
                    case 5:
                        std::cout &lt;&lt; &quot;E &quot;;
                        break;
                    case 6:
                        std::cout &lt;&lt; &quot;F &quot;;
                        break;
                    case 7:
                        std::cout &lt;&lt; &quot;G &quot;;
                        break;
                    case 8:
                        std::cout &lt;&lt; &quot;H &quot;;
                        break;

                    default:
                        break;
                }

            }
            std::cout &lt;&lt; xy[i][y];
        }
        std::cout &lt;&lt; std::endl;
    }
    std::cout &lt;&lt; std::endl;
}

void action(int *yfig, int *xfig, int *turnfig, int xheap, int yheap, std::string *xy[9][9])
{
    int mov1 = 0, mov2 = 0, mov3 = 0;
    int act = 0;

    std::cout &lt;&lt; &quot;Bewegen oder Schlagen? &quot;;
    std::cin &gt;&gt; act;
    switch (act) {
        case 1:
            switch (*turnfig) {
                case 0:
                    std::cout &lt;&lt; &quot;1 oder 2 Felder bewegen? &quot;;
                    std::cin &gt;&gt; mov1;
                    switch (mov1) {
                        case 1:
                            xheap = *xfig;
                            yheap = *yfig;
                            *yfig = *yfig+1;

                            *xy[yheap][xheap-1] = &quot;_   &quot;;
                            *xy[*yfig][*xfig-1] = &quot;wB1 &quot;;

                            break;
                        default:
                            xheap = *xfig;
                            yheap = *yfig;
                            *yfig = *yfig+2;

                            *xy[yheap][xheap-1] = &quot;_   &quot;;
                            *xy[*yfig][*xfig-1] = &quot;wB1 &quot;;
                            break;
                    }
                    break;
                case !0:

                    break;
            }
            break;
        case !1:

            break;
    }
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2394501</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2394501</guid><dc:creator><![CDATA[hihohohi]]></dc:creator><pubDate>Mon, 14 Apr 2014 09:18:38 GMT</pubDate></item><item><title><![CDATA[Reply to Schach - Pointer zum String on Mon, 14 Apr 2014 09:24:15 GMT]]></title><description><![CDATA[<p>mach aus std::string[][] einen std::vector&lt;std::vector<a href="std::string" rel="nofollow">std::string</a>&gt;. Den kannst du dann als Referenz übergeben.</p>
<p>Da die Größe bei dir konstant ist, würde sich auch ein std::array anstelle von std::vector anbieten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2394503</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2394503</guid><dc:creator><![CDATA[daddy_felix]]></dc:creator><pubDate>Mon, 14 Apr 2014 09:24:15 GMT</pubDate></item><item><title><![CDATA[Reply to Schach - Pointer zum String on Mon, 14 Apr 2014 09:31:08 GMT]]></title><description><![CDATA[<p>Zeile 69:</p>
<pre><code>void tout(std::string (&amp;xy)[9][9])
</code></pre>
<p>Zeile 113 äquivalent.</p>
<p>Mit std::array geht das aber trotzdem leichter und du bekommst kostenlose Zusatzfunktionen dazu.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2394504</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2394504</guid><dc:creator><![CDATA[nwp3]]></dc:creator><pubDate>Mon, 14 Apr 2014 09:31:08 GMT</pubDate></item><item><title><![CDATA[Reply to Schach - Pointer zum String on Mon, 14 Apr 2014 09:38:41 GMT]]></title><description><![CDATA[<p>danke schonmal für die schnellen Antworten,<br />
(die ich sogar verstehe ;))<br />
werde es sobald ich zeit habe direkt mal ausprobieren<br />
und werde wieder schreiben falls ich doch noch Probleme habe sollte.</p>
<p>Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2394505</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2394505</guid><dc:creator><![CDATA[hihohohi]]></dc:creator><pubDate>Mon, 14 Apr 2014 09:38:41 GMT</pubDate></item></channel></rss>