I have the following piece of code which works fine

data[person].history[data[person].trans]= "CASH WITHDRAWAL 100.00 GBP";

but how would I write it so instead of 100.00 it inputs a float called safe_input2

Recommended Answers

All 2 Replies

Assuming we're talking about a std::string object and not a pointer to char:

stringstream ss;

ss<<"CASH WITHDRAWAL "<< safe_input2 <<" GBP";
data[person].history[data[person].trans] = ss.str();

Assuming we're talking about a std::string object and not a pointer to char:

stringstream ss;

ss<<"CASH WITHDRAWAL "<< safe_input2 <<" GBP";
data[person].history[data[person].trans] = ss.str();

Thanks for the help, I'm still getting used to C++.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.