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.
重複の可能性: array[100] = {0} はどのように配列全体を 0 に設定しますか? 文字配列を初期化する方法は?
C++でchar配列を0s配列に初期化したい。これを行いますか ?"char a[4096] = {0};"
"char a[4096] = {0};"
はい、そうなります...しかし、存在はASCIIであることに注意してcharください0...機能NULLしないすべて'0'(文字0)に初期化する場合。
char
0
NULL
'0'
この場合:
memset(a, '0', 10);
行くためのより良い方法でしょうか...または
std::fill(std::begin(a), std::end(a), '0');
まだ良いでしょう。
はい。
(そして、この回答にも少なくとも 30 文字あります。)