Format Escape Zeichen als String Vorgabe?



  • Hallo,

    ich möchte mit einem CString einen anderen CString dynamisch anders erstellen lassen.

    CString MyString;
    int jahr=2020;
    int anzahl=4;
    MyString.Format("ich bin %d %d mal im Urlaub", jahr, anzahl);
    

    soll in etwa so aussehen

    CString MyString;
    int jahr=2020;
    int anzahl=4;
    CString MyFormat="ich bin %d %d mal im Urlaub";
    MyString.Format(MyFormat, jahr, anzahl);
    MyFormat="In the year %d I am %d times on holiday";
    MyString.Format(MyFormat, jahr, anzahl);
    

    Wie kann ich dynamisch mit einem String eine Formatvorgabe machen?

    Grüße,
    TheNoName



  • Und was ist da jetzt das Problem? Das erste Codebeispiel dürfte das doch umsetzen.



  • Das erste Beispiel ist wie es funktioniert, es geht um Beispiel 2.

    Mein Problem wird doch sein, das der CString vom zweiten Beispiel das Escape Kommando nicht in den String übernehmen wird und im Format daher nichts machen wird.


  • Mod

    thenoname schrieb:

    Mein Problem wird doch sein, das der CString vom zweiten Beispiel das Escape Kommando nicht in den String übernehmen wird und im Format daher nichts machen wird.

    Hä...Rembrandt... Bahnhof?
    Wieso nicht?


Anmelden zum Antworten