How to convert a 2D array into a single string in c++ -


am writing pathfinder , have 21x21 array want convert single string. array contain 1's , 0's. 1's placed in order form path.

my current relevant code snippet

std::string str;  for(int = 0; < 21; i++) {     for(int j = 0; j < 21; j++)     {         str += grid[i][j];     } }  std::cout << str; return (str); 

when run code jumps file containing static inline size_t length(const char_type* __s) {return strlen(__s);} , says exc_bad_access.

just use code in loop

str +=std::to_string(grid[i][j]); 

Comments

Popular posts from this blog

angular - DownloadURL return null in below code -

python 2.7 - Given three nested dictionaries, sort the top two nested dictionaries from a value in the innermost dictionary? -