3
3

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.

[const char*] with const_cast<char*>

3
Posted at

C/C++を書いていて文字列そのまま突っ込みたいと思ったりしても、配列の確保して、コピーしてとか普通やらないといけない。
でもC++のconst_castを使ってやると以下のように書ける。

char **params;
params = new char*[paramNum];
params[0] = const_cast<char*>("param1");
params[1] = const_cast<char*>("param2");

文字をそのまま突っ込む感じで書ける。

3
3
4

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
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?