|
![](/images/resource/spacer.gif) |
การตัดข้อความบางส่วน ในภาษา C++ ครับใช้ erase หรือ substr หรือครับ |
|
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
ใช้ setw()+setfill() หรือ printf()
Code (C++)
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int main() {
string x = "012";
int y = 5;
printf("x = %02d, y = %02d\n", stoi(x), y);
cout << "x = " << setw(5) << setfill('0') << x
<< ", y = " << setw(5) << setfill('0') << y << endl;
return 0;
}
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2022-09-13 09:22:44 |
By :
009 |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
|
|
|
![](/images/digitalocean-banner.jpg)
|
Load balance : Server 05
|