#include#include using namespace std; //转string模板函数template string toString(const T &v){ ostringstream os; os << v; return os.str();}int main() { int a = 4; float aa = 4.01; double dd = 33.566; string straa = toString(a); string straaa = toString(aa); string straab = toString(dd); cout << straa << endl; cout << straaa << endl; cout << straab << endl; return 0; }
int writeFile(string charFpName, string chVal) //写文件{ FILE *fp = fopen(charFpName.c_str(),"w+"); if(NULL == fp){ return 0; } fprintf(fp,"%s\n",chVal.c_str()); fclose(fp); return 1; }