[HH] c++ strings?
David Kramer
david at thekramers.net
Tue Nov 20 01:55:59 EST 2012
On 11/19/2012 11:48 PM, Greg London wrote:
>
> If this were perl I'd just do this:
>
> sub wrapper1{
> my ($string)=@_;
> othersub( "prefix ".$string."postfix");
> }
>
> but I can't seem to find a nice clean (not a lot of extra characters)
> way of doing this in C++.
>
> I googled around and found a couple of examples that said to
> use string streams and other classes.
>
> None of them seemed to compile for me.
>
> So, I need a way to write some code in C++ that makes it fairly
> easy to handle strings, concatentations, string literals, and such
> and pass it into other subrotines. I'd rather be able to avoid
> declaring the size of the string and just let them do the right thing.
>
> can anyone point me to a good URL for this?
You probably want sprintf, which is like printf except it outputs a
string instead of writing the output to stdout.
http://www.cplusplus.com/reference/clibrary/cstdio/sprintf/
More information about the Hardwarehacking
mailing list