c ライブラリ関数の定義はmemmove
次のようになります。
void* memmove(void *s1, const void *s2, size_t n)
{
char *sc1;
const char *sc2;
sc1 = s1;
sc2 = s2;
...
}
なぜvoid*
andconst void*
をパラメータの型として使用する必要があるのか 疑問に思っています。なぜ直接char*
ではないのconst char*
ですか?
アップデート
int test_case[] = {1, 2, 3, 4, 5, 6, 7, 8, 10};
memmove(test_case+4, test_case+2, sizeof(int)*4);
出力: test_case = {1, 2, 3, 4, 3, 4, 5, 6, 10}