Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Jun 2003
    Messaggi
    4,826

    [c++ stl]format di stringa

    CIao.
    Scusate la stupidita della domanda , ma è poco che sto studiando stl.
    COme faccio a formattare una stringa per esempio:

    string str= "ciao n° %n";
    int i = 1;
    formattare con il placeholder:
    string strFormattata = format(str, i);

    strFormattata dovrebbe essere;
    "ciao n° 1"
    grazie.

  2. #2
    Utente di HTML.it L'avatar di shodan
    Registrato dal
    Jun 2001
    Messaggi
    2,381
    In C++ si può fare.
    codice:
    ostringstream oss;
    int i = 1;
    oss << "ciao n° " << i;
    string strFormattata = oss.str();
    This code and information is provided "as is" without warranty of any kind, either expressed
    or implied, including but not limited to the implied warranties of merchantability and/or
    fitness for a particular purpose.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.