Skip to content

Instantly share code, notes, and snippets.

@Beyarz
Last active February 16, 2019 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Beyarz/e70f7bfc1e248721ffaee9c1fd100202 to your computer and use it in GitHub Desktop.
Save Beyarz/e70f7bfc1e248721ffaee9c1fd100202 to your computer and use it in GitHub Desktop.
Merge array into string
#include <stdio.h>
#include <string.h>
#define BUF 64
int main()
{
char buffer[BUF] = {'a', 'b', 'c'};
char string[BUF] = "The following says: ";
char combine[BUF];
strcpy(combine, string);
for(int x = 0; x <= 2; x++){
combine[x+strlen(string)] = buffer[x];
}
puts(combine); # "The following says: abc"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment