I want to create a public api that takes a string as an argument and places this string at the loaction where I have placed a format specifer in another string in that Api.
e.g. string PrintMyMessage( const string& currentValAsString)
{
string s1("Current value is %s",currentValAsString);
return s1;
}
Currently I am getting following build Error.
1>d:\extra\creatingstrwithspecifier\creatingstrwithspecifier\main.cxx(8): error C2664: 'std::basic_string<_Elem,_Traits,_Ax>::basic_string(const std::basic_string<_Elem,_Traits,_Ax> &,unsigned int,unsigned int)' : cannot convert parameter 2 from 'const std::string' to 'unsigned int'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
I just want to know what could be a better way to accomplish this task.