掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
文字列操作の一般的な方法とは? (ID:67996)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
> sprintf( a, "KOTEI:%02d", data); > 的に書けると思うのですが 僕ならハイブリッド方式。 #include <cstdarg> #include <cstring> #include <string> std::string form(const char* format, ...) { char buf[512]; va_list args; va_start(args,format); vsprintf(buf, format, args); return buf; } #include <iostream> int main() { int data = 123; std::cout << form("KOTEI:%02d", data) << std::endl; }
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.