Making a char array with an int in it
So I'm making a bunch of histograms and I need to set their titles in a for loop.
What I need is to say "Fiber #i", with i being the number.
Basically my code needs to be
histogram hists[128] = new histogram();
for (i = 0; i < 128, i++)
{
hists[i].SetTitle("Fiber #" + i);
} |
I'm not really sure what to put inside SetTitle though. It takes an argument const char * title.
Last edited on
The recommended approach in C++ would involve using a string stream. sprintf is a viable alternative also. Some examples:- http://codepad.org/HMGAoOku
Topic archived. No new replies allowed.