Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

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!
 
PREVIOUS NEXT
Tagged: #join #array #strings
ADD COMMENT
Topic
Name
8+3 =