ページ 11

無題

Posted: 2009年5月30日(土) 17:45
by C
入力した文字列の文字数を出力するプログラムを教えてください。

Re:無題

Posted: 2009年5月30日(土) 17:52
by non
wcslen関数を使えばよいのでは?

Re:無題

Posted: 2009年5月30日(土) 17:55
by たかぎ
#include <iosfwd>
#include <string>

template <class C, class Traits = std::char_trais<C> >
void foo(std::basic_istream<C, Traits>& istr, std::basic_ostream<C, Traits>& ostr)
{
  std::basic_string<C, Traits> str;
  istr >> str;
  ostr << str.size();
}
こういうことでしょうか?