-1

I am trying to write a sentence inside a stringstream. Here is my sketch:

stringstream is;
float position_angle0;

position_angle0=12.5;

is << "setpos1 0 %d ", int(position_angle0);

I guess there is something wrong because it seems not working. Can you please tell me the correct way to do this?

mskfisher
  • 3,291
  • 4
  • 35
  • 48

2 Answers2

1

Standard streams do not take type format specifiers – there's no need, as they're already implicitly type-safe.

is << "setpos1 0 " << static_cast<int>(position_angle0) << ' ';
ildjarn
  • 62,044
  • 9
  • 127
  • 211
1

It should look like this:

is << "setpos1 0 " << static_cast<int>(position_angle0);
Tony The Lion
  • 61,704
  • 67
  • 242
  • 415