28 lines
598 B
C
28 lines
598 B
C
#include <stdio.h>
|
|
// TODO: Include the approriate headers
|
|
#include <stdlib.h>
|
|
char* concat(char* first, char* second)
|
|
{
|
|
// TODO: allocate dynamic memory and copy both strings to it
|
|
char* both = malloc(sizeof(char) * 13);
|
|
int x = 0;
|
|
while (first[x] != 0) {
|
|
both[x] = first[x];
|
|
x++;
|
|
}
|
|
int y = 0;
|
|
while (second[y] != 0) {
|
|
both[x + y] = second[y];
|
|
y++;
|
|
}
|
|
return both;
|
|
}
|
|
int main(int argc, const char *argv[])
|
|
{
|
|
char hello[] = "Hello";
|
|
char world[] = "World!";
|
|
|
|
char* out = concat(hello, world);
|
|
printf("%s", out);
|
|
}
|