1. 程式人生 > >C++小技巧彙總

C++小技巧彙總

// “d:\錄取i.txt”改成”d:\錄取‘’+i +“.txt”
string filename = “d:\錄取”;
char index = i + ‘0’;//數字i轉換成字元i
filename = filename + index + “.txt”;
ofile.open(filename.c_str());

int轉string
int n = 0;
std::stringstream ss;
std::string str;
ss<

include “stdafx.h”

include

include

using namespace std;
void main()
{
// int 轉 string
stringstream ss;
int n = 123;
string str;
ss<