可以,有一个函数叫做itoa,可以把整数转为字符串!还有itof,atoi等几个函数,在网上一搜就知道用法了!
#include
#inlcude
using namespace std ;
int main()
{
long id ;
cout << "input book no:" ;
cin >> id ;
char filename[100];
sprintf( filename, "c:\\%d" , id );
ofstream outfile( filename );
outfile << "this is a test!\n" ;
outfile.close();
return 0;
}