库函数, string , integer to char


#include <stdio.h> //use of itoa: integer to char //puts output char* //convert string to char* //string name with accumulated acount. string sName = "book-"; int iCount; char cBuffer[3]; itoa(iCount, cBuffer, 10); if(iCount < 10) sName += "00"; if(iCount < 100) sName += "0"; if(iCount >= 1000) std::cerr << "no valid name index" << std::endl; sName += cBuffer; puts(sName .c_str() );
原文地址:https://www.cnblogs.com/aprilapril/p/2969897.html