Answers for "how to join an array of strings c"

C
0

how to join an array of strings c

#include <string.h>

char** myArray = { "hello", "world", "hello", "world", "wow!" };

char* query = myArray[0]; // you can also set this to ""

int i = 1;
while (myArray != NULL)
{
  strcat(query, " "); // add a space first
  strcat(query, myArray[i]);
  i++;
}

printf(myArray);

// hello world hello world wow!
Posted by: Guest on May-04-2022

Code answers related to "how to join an array of strings c"

Code answers related to "C"

Browse Popular Code Answers by Language