Last active
February 16, 2019 14:05
-
-
Save Beyarz/e70f7bfc1e248721ffaee9c1fd100202 to your computer and use it in GitHub Desktop.
Merge array into string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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