Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
src配列に含まれていない場合、strdupが新しい配列の最後に「\ 0」を追加するかどうかを知りたいですか?
この種のmallocによって割り当てられた「hello」を含む配列があると仮定しましょう
malloc(sizeof(char) * 5);
つまり、5 文字で 5 バイトです。
src 文字列が '\0' に十分なメモリを受け取っていないと思います。
この場合、何が起こるはずですか?