Adding extension to a string.

This is what I've got:
1
2
3
4
5
6
7
8
9
10
11
private: System::Void champName1_TextChanged(System::Object^  sender, System::EventArgs^  e) {
			 Bitmap^ myImage;
			 String^ Location = "\\images\\";
			 String^ ChampName = Convert::ToString(champName1->Text);
			 String^ iImage;
			 iImage = ("%s%s.jpg", Location, ChampName);
			 lblTest->Text = iImage; // Prints just ChampName
			 myImage = gcnew Bitmap(iImage);
			 pctChamp1->Image = dynamic_cast<Image^>(myImage);
		 }
};

Basically what I tried to do is get the text from the dropdown menu, in this case the champName1->Text and add it to a string with the extension .jpg so the image will be automaticaly switched depending on the choice.
It wasn't working so I decided to create a label (in this case lblTest)so I can check the string itself..It prints just the champName1->Text, without the \\images\\ nor the .jpg extension.
Thank you in advance for your time and replies!
if you use std::string, you can just use the += operator:
1
2
3
std::string iImage = "\\images\\";
iImage += Convert::ToString(champName1->Text);
iImage += ".jpg";


Question: What does the ^ character do in your code? I only know about its bitwise XOR functionality. What does it do in this situation?
Last edited on
Well I wanted to use std::string but it gave me more problems than it solved, so I searched about defining strings in Form application and I found that String^ myString would help it
closed account (z05DSL3A)
In C++/CLI, String^ myString is a handle to a String. A handle is used to access a .NET reference types.
Managed to do it using
 
 iImage = Location + ChampName + ".jpg";

Thank you anyway xD
Topic archived. No new replies allowed.