Skip to content

Instantly share code, notes, and snippets.

@calebreister
Last active January 3, 2016 06:09
Show Gist options
  • Save calebreister/8420642 to your computer and use it in GitHub Desktop.
Save calebreister/8420642 to your computer and use it in GitHub Desktop.
Simple program to convert an array to a string.
#include <iostream>
#include <string>
using namespace std;
int main()
{
int array[2][2] =
{ 1, 2, 3, 4 };
string converted = "{";
for ( int h = 0; h < 2; h++ )
{
for (int w = 0; w<2; w++)
{
converted += to_string(array[h][w]);
if (w!=1)
converted += ",";
else
converted += ";";
}
}
//erase final semicolon
converted.erase(converted.length() -1);
converted += "}";
cout << converted;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment