How would I take seperate characters given by a 2d array and
How would I take seperate characters given by a 2d array and put them together as one string?
example below:
printf(\"%c\", grid[4][2]) which prints out H
printf(\"%c\", grid[2][1]) which prints out I
How would I put grid[4][2] and grid[2][1] together to make the string Hi? I don\'t just need to print it out, I need to put together an actual string.Again, I don\'t need to print this but store it as a seperate char string.
Any help would be greatly appreciated, will rate. Thank you
How would I take seperate characters given by a 2d array and put them together as one string?
example below:
printf(\"%c\", grid[4][2]) which prints out H
printf(\"%c\", grid[2][1]) which prints out I
How would I put grid[4][2] and grid[2][1] together to make the string Hi? I don\'t just need to print it out, I need to put together an actual string.Again, I don\'t need to print this but store it as a seperate char string.
Any help would be greatly appreciated, will rate. Thank you
How would I take seperate characters given by a 2d array and put them together as one string?
example below:
printf(\"%c\", grid[4][2]) which prints out H
printf(\"%c\", grid[2][1]) which prints out I
How would I put grid[4][2] and grid[2][1] together to make the string Hi? I don\'t just need to print it out, I need to put together an actual string.Again, I don\'t need to print this but store it as a seperate char string.
Any help would be greatly appreciated, will rate. Thank you
Solution
See this is a static requirement you can do like this
you can create a char array of size 2 to accomodate the 2 characters like shown below :
char final_str[2]; // create char string
final_str[0]=grid[4][2]; // assign first character
final_str[1]=grid[2][1]; //assign second character
