Type: Note
C sprintf - 使用時間當做範例
#include <time.h> time_t timep; struct tm *p; time(&timep); p=gmtime(&timep); sprintf(fn, "t%02d%02d%02d", p->tm_hour, p->tm_min, p->tm_sec);
C++ ostringstream
#include <string> #include <sstream> int no = 12; std::ostringstream oss; oss << "data_" << no << ".text"; std::string str = oss.str(); printf("%s\n", str.c_str());
沒有留言:
張貼留言