Hello
I am having trouble converting int to const char*.
Here is the code :
{
std::vector<int> ids = m_gui->get_config()->ids();
int k =0;
for (std::vector<int> :: const_iterator ich = ids.begin(); ich!= ids.end(); ++ich)
{
//cout<<(*ich);
id_box[k]->AddEntry(*ich,0);
k++;
}
}
- {
- std::vector<int> ids = m_gui->get_config()->ids();
-
- int k =0;
- for (std::vector<int> :: const_iterator ich = ids.begin(); ich!= ids.end(); ++ich)
- {
- //cout<<(*ich);
- id_box[k]->AddEntry(*ich,0);
- k++;
- }
- }
I am getting a bunch of numbers (16, 17, ...., ) = ids, and I am trying to put them into boxes with AddEntry.
Notice that when I compile everything that cout statement works and lists the ids I want.
The error I get is this :
call of overloaded ‘AddEntry(const int&, int)’ is ambiguous
/usr/local/root/include/TGListBox.h:318: note: candidates are: virtual void TGListBox::AddEntry(TGString*, Int_t) <near match>
/usr/local/root/include/TGListBox.h:319: note: virtual void TGListBox::AddEntry(const char*, Int_t) <near match>
/usr/local/root/include/TGListBox.h:320: note: virtual void TGListBox::AddEntry(TGLBEntry*, TGLayoutHints*) <near match>
==========================================
Now, I know that the error is coming because AddEntry( ) wants a 'const char*' in it and not an 'int*' .
My question is, how do I convert the int to a char ?
I have tried various things like :
char str[10];
str=itoa(ich, str, 10);
- char str[10];
- str=itoa(ich, str, 10);
Doesnt work!
Any suggestions would be awesome!
thanks
Moderator Remark: Please make sure you put [cpp][/cpp] or [code][/code] tags around code in your post to make it easier to read. Thanks!