0

I've commandLine arguments in a C++/CLI program denoted by char* argv[]. I want to transfer all the contents getting concatenated to a String^ class.

Code:

String ^masterString = "Commands=>";

for(int i=0; argv[i] != nullptr; ++i)
masterString += String(argv[i]);

However, I find the above not working in the last statement where I use += operator.

  1. What's the wrong usage here? Error here is No operators match the operands.

  2. Any other better ways to store contents into String^ from char*?

stack_pointer is EXTINCT
  • 2,263
  • 12
  • 49
  • 59

1 Answers1

0

Look into MSDN, mostly into this:

#include <stdlib.h>
#include <string.h>
#include <msclr\marshal.h>

using namespace System;
using namespace msclr::interop;

int main() {
   const char* message = "Test String to Marshal";
   String^ result;
   result = marshal_as<String^>( message );
   return 0;
}

btw: I didn't check this. Just googled it. But, I think, this would work, cause it posted in MSDN.

m0nhawk
  • 22,980
  • 9
  • 45
  • 73