Norbrecht
Norbrecht

Reputation: 51

ByteArray in c++

In C# to send the post data(WebRequest) I used this code:

string postData = "username=" + UsernameInput.Text + "&password=" + PasswordInput.Text;
byte[] byteArray = Encoding.UTF8.GetBytes(postData);

How do I import this code to c++.

Upvotes: 1

Views: 132

Answers (2)

Rahul Tripathi
Rahul Tripathi

Reputation: 172628

Just trying to put the answer which you have actually put with the question(So that it may help someone in future):-

String^ postData = "username=" + UsernameInput->Text + "&password=" + PasswordInput->Text;
array<Byte>^byteArray = Encoding::UTF8->GetBytes(postData);

Upvotes: 1

galop1n
galop1n

Reputation: 8824

std::string is also a container so :

std::string postData = ... ;
std::vector<std::string::value_type> bytes( postData.begin(), postData.end() );

That's all.

Upvotes: 0

Related Questions