CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Threaded View

  1. #1
    Join Date
    Nov 2002
    Location
    Los Angeles, California
    Posts
    3,863

    Problem with conversion to hex string.

    Can anyone see why this code produces the string "0" when 0x00 is plugged into
    it instead of 0x00.
    It works fine with 0xff for example.

    Code:
    template <typename CT, typename T> //PARAMETERIZED OVER CHARACTER AND NUMERIC TYPE TO BE CONVERTED
    std::basic_string<CT> CONVERT_TO_STRING(const T& t, std::ios_base & (*f)(std::ios_base&), const  std::streamsize precision)
    {
    	std::basic_ostringstream<CT> oss;
    	oss.setf(std::ios::showbase);
    	oss <<std::fixed<<std::setprecision(precision)<< f << t;
    	return oss.str();
    };
    
    CONVERT_TO_STRING<char>(0x00, std::hex, 0)
    Last edited by souldog; October 27th, 2004 at 03:04 PM.
    Wakeup in the morning and kick the day in the teeth!! Or something like that.

    "i don't want to write leak free code or most efficient code, like others traditional (so called expert) coders do."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured