Last active
January 3, 2016 06:09
-
-
Save calebreister/8420642 to your computer and use it in GitHub Desktop.
Simple program to convert an array to a string.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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