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.
動的 char 配列を作成する場合:
char * c = new char[5];
そして、私はそれを文字列で埋めません.ヌル文字\0はこの配列の最後にありますか?
\0
いいえ、char ポインターは単なるポインターです。配列を指す必要さえありません。
特定のケースでは、新しい配列の要素は初期化されていません。それらをゼロで初期化したい場合は、これを行うことができます:
char * c = new char[5]();
これにより、すべての要素が に設定され\0ます。cnull で終わる文字列を指すことを検討できます。
c