1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

POSIX > strdup() > 文字列のコピー > C99にもC11にも含まれていない

Last updated at Posted at 2015-04-20

引用: C/C++ セキュアコーディング 第2版 by Robert C. Seacordら

strdup()は文字列へのポインタを受け取り、新しく確保したメモリに複製した文字列へのポインタを返す。このメモリを解放するためには、戻り値のポインタを指定してfree()を実行すればよい。

...
ISO/IEC TR 24731-2[ISO/IEC TR 24731-2:2010]で定義されているが、C99にもC11にも含まれていない。

http://fernweh.jp/b/c-allocation/#id-3
にサンプルコードが掲載されている。

ideoneにて実際にコーディングしてみた。

1
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?