[HH] c++ strings?
Matthew Gillen
me at mattgillen.net
Tue Nov 20 13:02:39 EST 2012
On 11/20/2012 12:41 PM, Greg London wrote:
> In perl, it might look like this:
>
> sub upper_subroutine{
> my ($string)=@_;
> lower_subroutine("prefix".$string."postfix".timestamp());
> }
>
> Could someone give me an example of how to do this in C++ so that
> it looks as close to this perl code as possible?
This will be useful to you for getting the timestamp aspect:
http://www.tutorialspoint.com/cplusplus/cpp_date_time.htm
Other than that, use the '+' operator to concatenate C++ string objects,
much like you use the '.' operator in perl.
Note that you can run into issues if neither of the operands to '+' are
actual std::string objects (e.g. "foo" + "bar" doesn't work in C++ like
it would in perl, since the literal string is not automatically promoted
to std::string in some cases).
> If this could happen without anyone having to die, that would
> be even better.
That's asking a lot ;-)
Matt
More information about the Hardwarehacking
mailing list