[HH] c++ strings?

Greg London email at greglondon.com
Thu Dec 13 08:03:21 EST 2012


Sorry, this seems like it would be easy, but I'm stumped.

I bring in two integers and a string, and I want to
create another string that contains the
integers in hex format and the first string.

It would be one line in perl or verilog.

I can't get it to work at all in C++.
And every example I've seen so far using stringstream
seems to require many, many lines of code.


void ActualExpected(int actual, int expected, const string &msg){
	stringstream ss;


the next line would hopefully be something like this:

        ss << "actual=0x" << [actual in string hex format]
           << "expected=0x " << [expected in string hex format]
           << msg;

But for the life of me, I can't get any examples to work.
And all the examples use several lines of code.


Greg





More information about the Hardwarehacking mailing list