Making a second attempt.
string = Hello
'use code to remove 'O' from hello
string = Hell
, how can you achieve such without copying the original string.
'a challenge'
Printable View
Making a second attempt.
string = Hello
'use code to remove 'O' from hello
string = Hell
, how can you achieve such without copying the original string.
'a challenge'
What about replacing the last character with a null character?
Code:#include <string.h>
char msg[] = "Hello";
msg[strlen(msg)-1] = '\0';
One solution is erase();
KuphrynCode:std::string sText = "NovemberX";
sText.erase( // Position
9,
// Number of elements.
1);
string = Hello
'use code to remove 'O' from hello
string = Hell
, how can you achieve such without copying the original string.
'a challenge'
one avenue you could go down is create an
array [4] {"hello"}; //this will set it up as an array of 5 letters but we have set the element to 4. Now just creat an output for it and you should be ready to go.
cout << name_of_your_output;
I hope this gets you started in the right direction. Good Luck!!
cj
( i solved it like this ) *take in context it's C++ Builder*
Since i had no idea how to (mouse click is the listbox value) i had to figure out how i could assign (as doggiesnot stated) ListBox1->Items->Strings[i] , Getting [i] was very difficult,but it was the right choise.
My code became the Following
Added 1 CSpinEdit1.
This gave a clean string without the garbage.Code:SpinEdit1->Value = ListBox1->ItemIndex;
Edit4->Text = ListBox1->Items->Strings[CSpinEdit1->Value];
So instead of trying to delete the separators and since i invested much time in getting code trying to erase newline's , i ditched that idea did like above, and came to a solution.
Thank you so much. And also for everyone elses views in this.