<?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[string replace]]></title><description><![CDATA[<p>Ich suche jetzt schon wieder bald seit 2 Stunden aber bekomm es nicht heraus wie bekomm ich von einem OpenDialog der mir den</p>
<pre><code class="language-cpp">ofn.lpstrFile
</code></pre>
<p>zurück gibt einen Pfad den mein Programm auch verwenden kann sprich es muss anstatt jedem \ ein \\ sein oder habe ich schon wieder etwas falsch verstanden.</p>
<p>Ich bin am verzweifeln mit string.replace komm ich auch nicht weiter bitte helft mir</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/278254/string-replace</link><generator>RSS for Node</generator><lastBuildDate>Tue, 25 Aug 2026 08:31:38 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/278254.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 02 Dec 2010 16:48:19 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to string replace on Thu, 02 Dec 2010 16:48:49 GMT]]></title><description><![CDATA[<p>Ich suche jetzt schon wieder bald seit 2 Stunden aber bekomm es nicht heraus wie bekomm ich von einem OpenDialog der mir den</p>
<pre><code class="language-cpp">ofn.lpstrFile
</code></pre>
<p>zurück gibt einen Pfad den mein Programm auch verwenden kann sprich es muss anstatt jedem \ ein \\ sein oder habe ich schon wieder etwas falsch verstanden.</p>
<p>Ich bin am verzweifeln mit string.replace komm ich auch nicht weiter bitte helft mir</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1989197</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1989197</guid><dc:creator><![CDATA[thefiloe]]></dc:creator><pubDate>Thu, 02 Dec 2010 16:48:49 GMT</pubDate></item><item><title><![CDATA[Reply to string replace on Thu, 02 Dec 2010 17:15:35 GMT]]></title><description><![CDATA[<p>thefiloe schrieb:</p>
<blockquote>
<p>es muss anstatt jedem \ ein \\ sein oder habe ich schon wieder etwas falsch verstanden.</p>
</blockquote>
<p>Du hast schon wieder etwas falsch verstanden.<br />
Probiers doch einfach mal ohne dein replace aus.</p>
<p>Der Vollständigkeit halber: Ein char-replace sieht in C++ so aus:</p>
<pre><code class="language-cpp">std::string s(ofn.lpstrFile)
for (string::size_type pos; (pos = str.find('\\', pos)) != string::npos; ++pos)
   s.replace(pos, 1, &quot;\\\\&quot;);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1989206</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1989206</guid><dc:creator><![CDATA[thetrutho]]></dc:creator><pubDate>Thu, 02 Dec 2010 17:15:35 GMT</pubDate></item><item><title><![CDATA[Reply to string replace on Thu, 02 Dec 2010 17:28:27 GMT]]></title><description><![CDATA[<p>ofn.lpstrFile kann direkt verwendet werden.<br />
Warum? Eine Zeichenkette ist eine Aneinanderreihung von chars, die alle einen bestimmten Wert haben. Schau dir mal in Ruhe die <a href="http://www.tcp-ip-info.de/tcp_ip_und_internet/ascii.htm" rel="nofollow">ASCII-Tabelle</a> an.<br />
Der Backslash hat den dezimalen Wert 92, steht er in der Zeichenkette, wird er natürlich richtig interpretiert.</p>
<p>Anders im Editor: Nachdem der Compiler einen Backslash erkennt, wertet er das nächste Zeichen direkt als <code>Escape Sequence</code> aus (falls er sie nicht kennt, gibt es eine Warnung).<br />
Dies sind z.B. '\n','\r','\&quot;' und eben auch '\'.<br />
Daher kann man im Editor &quot;c:\\neuer ordner&quot; schreiben, &quot;c:\neuer ordner&quot; führt nicht zum Ziel, da '\n' als (falsche) Escapesequenz gewertet wird.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1989207</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1989207</guid><dc:creator><![CDATA[Vicious Falcon]]></dc:creator><pubDate>Thu, 02 Dec 2010 17:28:27 GMT</pubDate></item><item><title><![CDATA[Reply to string replace on Thu, 02 Dec 2010 17:23:16 GMT]]></title><description><![CDATA[<p>EDIT: ich habe herausgefunden wenn ich das lied direkt von C:\... hole gehts sobald ich in das standartmäßige musik verzeichnis komme nicht mehr wieso?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1989209</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1989209</guid><dc:creator><![CDATA[thefiloe]]></dc:creator><pubDate>Thu, 02 Dec 2010 17:23:16 GMT</pubDate></item><item><title><![CDATA[Reply to string replace on Thu, 02 Dec 2010 17:24:52 GMT]]></title><description><![CDATA[<p>Code zeigen!<br />
Ins Blaue hinein würde ich tippen, dass der Buffer zu klein ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1989213</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1989213</guid><dc:creator><![CDATA[Vicious Falcon]]></dc:creator><pubDate>Thu, 02 Dec 2010 17:24:52 GMT</pubDate></item><item><title><![CDATA[Reply to string replace on Thu, 02 Dec 2010 18:45:12 GMT]]></title><description><![CDATA[<p>hier ist der code:</p>
<p>ich weiß ist sicher unsauber aber ist eben eines der ersten Projekte ohne mein Buch...</p>
<p>sry</p>
<pre><code class="language-cpp">/* 
 * File:   main.cpp
 * Author: Florian
 *
 * imports dll
 *
 * Created on 29. November 2010, 18:34
 */

#include &lt;iostream&gt;
#include &lt;windows.h&gt;
#include &quot;bass.h&quot;

using namespace std;

//form structures
    //OpenfileDia
        OPENFILENAME ofn;       
        char szFile[260];       
        HWND hwnd;                        

DWORD flags[4]={BASS_SPEAKER_FRONT,BASS_SPEAKER_REAR,BASS_SPEAKER_CENLFE,BASS_SPEAKER_REAR2};
HSTREAM chan[4];

void OpenfileDia(void);

int main(void) {
    //int speaker=LOWORD(w)-10;
        //vars:

    int iChanPlace = 0;
    int iLenght = 0;
    int iPosition = 0;
    int iProgressBarValue = 0;

    OpenfileDia();

    BASS_Init(-1,44100,0,0,0); //bei console ist handle NULL bei window müsste so sein:     HWND handle;     BASS_Init(-1,44100,0,handle,0,0);
    BASS_StreamFree(chan[iChanPlace]); // free old stream before opening new
    if (!(chan[0]=BASS_StreamCreateFile(FALSE,ofn.lpstrFile,0,0,flags[iChanPlace]|BASS_SAMPLE_LOOP))) {
         cout &lt;&lt; &quot;Err&quot; &lt;&lt; endl;
         return 1;
    }

    BASS_ChannelPlay(chan[iChanPlace],FALSE);
     while ( 0 &lt; 1)
     {
        cout &lt;&lt; &quot;playing&quot; &lt;&lt; endl;
        iLenght = BASS_ChannelGetLength(chan[iChanPlace],BASS_POS_BYTE);
        iPosition = BASS_ChannelGetPosition(chan[iChanPlace],BASS_POS_BYTE);
        iProgressBarValue = (iPosition * 100) / iLenght;
        cout &lt;&lt; &quot;--&lt;&quot;;
        for(int i = 0; i &lt;= iProgressBarValue; i++ ){
            cout &lt;&lt; &quot;#&quot;;
        }

        for(int i = 0; i &lt;= 100-iProgressBarValue; i++){
            cout &lt;&lt; &quot;-&quot;;
        }

        cout &lt;&lt; &quot;&gt;--&quot;;

        Sleep(1000);

        system(&quot;cls&quot;);
     }
    return 0;
}

void OpenfileDia(void){

ZeroMemory(&amp;ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hwnd;
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = &quot;All\0*.*\0Text\0*.TXT\0&quot;;
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;

if (GetOpenFileName(&amp;ofn)==TRUE){
    cout &lt;&lt; &quot;geöffnet&quot; &lt;&lt; endl;
}

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1989247</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1989247</guid><dc:creator><![CDATA[thefiloe]]></dc:creator><pubDate>Thu, 02 Dec 2010 18:45:12 GMT</pubDate></item><item><title><![CDATA[Reply to string replace on Thu, 02 Dec 2010 19:25:16 GMT]]></title><description><![CDATA[<p>Die aufrufende Funktion kann nicht herausfinden, ob eine Auswahl in OpenfileDia getroffen wurde. Sprich, die Funktion sollte über Erfolg oder Misserfolg Auskunft geben. Globale Variablen sind hier total überflüssig und sollten vermieden werden.</p>
<pre><code class="language-cpp">bool OpenfileDia(HWND hwnd, char* file, int len)
{
	OPENFILENAME ofn;
	ZeroMemory(&amp;ofn, sizeof(OPENFILENAME));
	ofn.lStructSize = sizeof(OPENFILENAME);
	ofn.hwndOwner = hwnd;
	ofn.lpstrFile = file;
	ofn.nMaxFile = len;
	ofn.lpstrFilter = &quot;All\0*.*\0Text\0*.TXT\0&quot;;
	ofn.nFilterIndex = 1;
	ofn.lpstrFileTitle = NULL;
	ofn.nMaxFileTitle = 0;
	ofn.lpstrInitialDir = NULL;
	ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
	return (GetOpenFileName(&amp;ofn));
}
</code></pre>
<p>Die Funktion wird jetzt mit Parametern aufgerufen, die lokal gehalten werden können:</p>
<pre><code class="language-cpp">char szFile[MAX_PATH];
if(OpenfileDia(GetConsoleWindow(),szFile,MAX_PATH))
{
  cout &lt;&lt; szFile &lt;&lt; endl;
  // jetzt mit szFile arbeiten
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1989283</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1989283</guid><dc:creator><![CDATA[Vicious Falcon]]></dc:creator><pubDate>Thu, 02 Dec 2010 19:25:16 GMT</pubDate></item><item><title><![CDATA[Reply to string replace on Fri, 03 Dec 2010 17:19:43 GMT]]></title><description><![CDATA[<p>ich verstehs nicht ich geb ihm genau das gleiche als parameter mit wie vorhin in den globalen variabeln und es funktioniert aber nicht.</p>
<p>Bei dem alten code:</p>
<p>siehe oben habe ich gepostet</p>
<p>geht es gut</p>
<p>hier nicht:</p>
<pre><code class="language-cpp">/*
 * File:   main.cpp
 * Author: Florian
 *
 * imports dll
 *
 * Created on 29. November 2010, 18:34
 */
#define _WIN32_WINNT 0x600  // Windows XP = 0501H; Vista 0600
#include &lt;iostream&gt;
#include &lt;windows.h&gt;
#include &quot;bass.h&quot;

using namespace std;

DWORD flags[4]={BASS_SPEAKER_FRONT,BASS_SPEAKER_REAR,BASS_SPEAKER_CENLFE,BASS_SPEAKER_REAR2};
HSTREAM chan[4];
OPENFILENAME ofn;

bool OpenFileDia(HWND,char*);

int main(void) {
    //int speaker=LOWORD(w)-10;
        //vars:

    int iChanPlace = 0;
    int iLenght = 0;
    int iPosition = 0;
    int iProgressBarValue = 0;
    //openfile
    char szFile[260];
    //--
    cout &lt;&lt; &quot;Adresse in Funktion : &quot; &lt;&lt; &amp;szFile &lt;&lt; endl;
    OpenFileDia(GetConsoleWindow(), szFile);
    BASS_Init(-1,44100,0,0,0); //bei console ist handle NULL bei window müsste so sein:     HWND handle;     BASS_Init(-1,44100,0,handle,0,0);
    BASS_StreamFree(chan[iChanPlace]); // free old stream before opening new
    if (!(chan[0]=BASS_StreamCreateFile(FALSE,ofn.lpstrFile,0,0,flags[iChanPlace]|BASS_SAMPLE_LOOP))) {
         cout &lt;&lt; &quot;Err&quot; &lt;&lt; endl;
         return 1;
    }

    BASS_ChannelPlay(chan[iChanPlace],FALSE);
     while ( 0 &lt; 1)
     {
        cout &lt;&lt; &quot;playing&quot; &lt;&lt; endl;
        iLenght = BASS_ChannelGetLength(chan[iChanPlace],BASS_POS_BYTE);
        iPosition = BASS_ChannelGetPosition(chan[iChanPlace],BASS_POS_BYTE);
        iProgressBarValue = (iPosition * 100) / iLenght;
        cout &lt;&lt; &quot;--&lt;&quot;;
        for(int i = 0; i &lt;= iProgressBarValue; i++ ){
            cout &lt;&lt; &quot;#&quot;;
        }

        for(int i = 0; i &lt;= 100-iProgressBarValue; i++){
            cout &lt;&lt; &quot;-&quot;;
        }

        cout &lt;&lt; &quot;&gt;--&quot;;

        Sleep(1000);

        system(&quot;cls&quot;);
     }
    return 0;
}

bool OpenFileDia(HWND hwnd,char* file){

ZeroMemory(&amp;ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hwnd;
ofn.lpstrFile = file;
ofn.nMaxFile = sizeof(file);
ofn.lpstrFilter = &quot;All\0*.*\0Mp3's\0*.MP3\0&quot;;
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;

cout &lt;&lt; &quot;Adresse in Funktion : &quot; &lt;&lt; &amp;file &lt;&lt; endl;
return GetOpenFileName(&amp;ofn);

}
</code></pre>
<p>aber ich habe auch eine vermutung:</p>
<p>Ich habe zwar noch sogut wie nie mit zeigern gearbeitet aber müsste die Adresse von file in der Funktion OpenFileDia nicht gleich wie sein wie die Adresse in der Main-Funktion von szFile...</p>
<p>Entschuldigung, dass ich mich hier so Anfängermäßig verhalte aber ich gebe mir wirklich mühe und bin immer bevor ich hier was poste 1-2 Stunden am suchen also sorry <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f623.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--persevering_face"
      title="&gt;.&lt;"
      alt="😣"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1989613</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1989613</guid><dc:creator><![CDATA[thefiloe]]></dc:creator><pubDate>Fri, 03 Dec 2010 17:19:43 GMT</pubDate></item><item><title><![CDATA[Reply to string replace on Fri, 03 Dec 2010 21:21:20 GMT]]></title><description><![CDATA[<p>Du gibtst für ofn.nMaxFile eine maximale Länge von sizeof(char*) an. Das ist genau die Größe eines Zeigers (32 Bit -&gt; 4 Byte, 64 Bit -&gt; 8 Byte).</p>
<p>Warum hast du die Funktion nicht übernommen, wie ich es geschrieben habe? Warum ist OPENFILENAME ofn immer noch global? Warum verwendest du überhaupt die restlichen globalen Variablen?</p>
<p>Das eigentliche Problem ist aber Folgendes: Du kannst durch einen Zeiger nicht auf den kompletten Bereich schließen, auf den er zeigt. Daher übergibt man in aller Regel die Größe des Bereichs gleich mit.</p>
<p>Um die Konvertierung von int nach bool zu vermeiden, kannst du auch</p>
<pre><code class="language-cpp">return (GetOpenFileName(&amp;ofn)?true:false);
</code></pre>
<p>schreiben. Der Returnwert sollte auch besser ausgewertet werden <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/1989666</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1989666</guid><dc:creator><![CDATA[Vicious Falcon]]></dc:creator><pubDate>Fri, 03 Dec 2010 21:21:20 GMT</pubDate></item><item><title><![CDATA[Reply to string replace on Fri, 03 Dec 2010 21:35:33 GMT]]></title><description><![CDATA[<p>danke nochmal und wieso ich deine funktion nicht genau so übernommen habe ist:</p>
<p>1. sie hat nicht funktioniert aber ich probier es jetzt mit den neuen infos nochmal und<br />
2. wollte ich auch einwenig selber was lernen :D, da ich nicht viel con c&amp;p halte...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1989668</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1989668</guid><dc:creator><![CDATA[thefiloe]]></dc:creator><pubDate>Fri, 03 Dec 2010 21:35:33 GMT</pubDate></item></channel></rss>