Jump to content
Hostul a fost schimbat. Daca vedeti serverul offline readaugati rpg.b-zone.ro sau 141.95.124.78:7777 in clientul de sa-mp ×

[C++] Formatarea unui string (variabile de tip char și string)


Andreigl
 Share

Recommended Posts

Să zicem că avem variabile de tip string și vrem să le unim. 

Vom proceda în felul următor:

std::string myFirstString = "Exemplu";
std::string mySecondString = "de formatare a unui string";
std::string finalString = myFirstString + ' ' + finalString;

 

Dacă afișăm finalString, output-ul va fi:

Exemplu de formatare a unui string

 

Dar dacă avem o variablă de tip char și una de tip string,

char myChar[10] = { 'S', 'h', 'a', 'n', 'k', 'e', 'r'};
std::string myString = "http://rpg.b-zone.ro/players/general/";
std::string formatedString = myString + myChar;

 

Dacă avem 2 variabile de tip char, atunci 1 va trebui transformată într-o variabilă de tip string:

char myChar[10] = { 'S', 'h', 'a', 'n', 'k', 'e', 'r'};
char myString[256] = "http://rpg.b-zone.ro/players/general/";
std::string chartoString = myString;
std::string formatedString = chartoString + myChar;

 

Edited by shanker'
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.