#include <stdio.h>

#include <string.h>


void myStrcat(char* a, char* b)

{

int m = strlen(a);

int n = strlen(b);

for (int i = 0; i <= n; i++)

a[m + 1] = b[i];

}


int main()

{

char* str1 = "Hello ";

char* str2 = "World";

myStrcat(str1, str2);

printf("%s", str1);

return 0;

}


교수님이 준 연습문젠데 여기서 오류를 고치래

str1, str2를 char[]로 고쳐보니까 원소 하나씩 변경은 가능한데 str1 쓰기범위 에러뜨고

그래서 realloc하려니까 메모리 주소가 바껴버려서 a만 바뀌고 str1에는 영향이 없어

내 짧은 지식의 한계가 온거같은데 형들 지식좀 빌려줘