I'm trying out my first project with visual C++, and I'm having a hard time figuring out a way to initialize a String from an array of char. I am taking an unsigned 32 bit integer as an IP address and generating the text equivalent of it. I felt it was easier to define an array of the maximum size, and parse the address into the array one element at a time then initialize a String based on the final null terminated character array than try to concat an existing String with the characters as I parse.
I am getting
IP_validate.cpp(170): error C2664: 'System::String::String(const wchar_t *)' : cannot convert parameter 1 from 'cli::array<Type> ^' to 'const wchar_t *'
1> with
1> [
1> Type=char
1> ]
as an error, and I'm having a very hard time implementing a solution. One promising way I found online was using Encoding::Convert, but I have yet to figure out how to actually make that work. Copy & pasting my code looks like a mess in the forum, so here is the important bits (The parsing of the numbers works fine, please assume that the array temp_ip_slate correctly contains the values for the IP address and is null terminated).
array<char>^ temp_ip_slate = gcnew array<char>(16); //An easier way to construct the ascii IP address (through array[element]) String^ temp_ip_string = gcnew String(temp_ip_slate); //The string used to construct the IP address, initialized with our finished IP address return(temp_ip_string); //Return the finished String backYou can see what I would LIKE to do, but there is no method to construct a String like that. What would be the easiest way to accomplish this?