array [index] = 0;の目的は何ですか?

チャウハン
char dev[20] = "dev_name";
char dest[32];
strncpy(dest,dev,sizeof(dev));
dest[sizeof(dev)-1] = 0;

どういうdest[sizeof(dev)-1] = 0;意味ですか?

Sourav Ghosh

あなたのコードでは、仮定sizeはに類似していますsizeof

 dev_name[size(dec_name)-1] = 0;

dev_name[size(dec_name)-1]配列の最後の要素を指しCます0配列はベースのインデックスを使用すること忘れないでください

次に、定義上、cの文字列は、外部的にはnullで終了するchar配列であるため、char配列を文字列として使用する場合は、nullで終了する必要があります。

0またはASCII値ですしたがって、基本的には、配列にnullターミネータを配置します。NULnullchar

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

'ptr =&array [index]'と '* ptr = array [index]'の違いは何ですか?

分類Dev

array [index]と[arrayobjectAtIndex:index]の違いは何ですか?

分類Dev

randomCounts [index] ++;の目的は何ですか?

分類Dev

std :: array <T、0>の目的は何ですか?

分類Dev

OpenGLの `glEnableVertexAttribArray(GLuint index)`の目的は何ですか?

分類Dev

javascriptのarray.entries()の目的は何ですか?

分類Dev

array [index] === undefinedは、typeof array [index] === 'undefined'と常に同じですか?

分類Dev

void * array = *(void **)member + siz *(* p_n);の目的は何ですか。

分類Dev

`std :: tuple_size <std :: array>`の目的は何ですか

分類Dev

新しいArray(9)構文の目的は何ですか?

分類Dev

「CursorIndexOutOfBoundsException:Index 0 requested、with a size 0」エラーの原因は何ですか?

分類Dev

std :: make_arrayの目的は何ですか/何でしたか?C ++ 20でもまだ必要ですか?

分類Dev

Array.prototype.slice.call(array、0)の用途は何ですか?

分類Dev

Array(0)とarray = []の違いは何ですか

分類Dev

FMDB and index 0 beyond bounds for empty array

分類Dev

index = 0の場合のXMVectorSetByIndexとXMVectorSetXの違いは何ですか?

分類Dev

このステートメントの背後にあるロジックは何ですか:for(-index; index> = 0; --index)?

分類Dev

array.sliceのコンテキストでのMath.maxの目的は何ですか

分類Dev

`[index:number]:string;`内の `index`の必要性は何ですか

分類Dev

長さ0の配列(またはstd :: array)の用途は何ですか?

分類Dev

Index Array without Elements

分類Dev

Index Array without Elements

分類Dev

Sort multidimensional array by index

分類Dev

SwiftUI - Indexset to index in array

分類Dev

array index out of bound

分類Dev

Get non-repeating index from array fails on 0

分類Dev

の実装は何ですか:+(instancetype)array;

分類Dev

「int mask =〜0;」の目的は何ですか?

分類Dev

varchar(0)の目的は何ですか

Related 関連記事

  1. 1

    'ptr =&array [index]'と '* ptr = array [index]'の違いは何ですか?

  2. 2

    array [index]と[arrayobjectAtIndex:index]の違いは何ですか?

  3. 3

    randomCounts [index] ++;の目的は何ですか?

  4. 4

    std :: array <T、0>の目的は何ですか?

  5. 5

    OpenGLの `glEnableVertexAttribArray(GLuint index)`の目的は何ですか?

  6. 6

    javascriptのarray.entries()の目的は何ですか?

  7. 7

    array [index] === undefinedは、typeof array [index] === 'undefined'と常に同じですか?

  8. 8

    void * array = *(void **)member + siz *(* p_n);の目的は何ですか。

  9. 9

    `std :: tuple_size <std :: array>`の目的は何ですか

  10. 10

    新しいArray(9)構文の目的は何ですか?

  11. 11

    「CursorIndexOutOfBoundsException:Index 0 requested、with a size 0」エラーの原因は何ですか?

  12. 12

    std :: make_arrayの目的は何ですか/何でしたか?C ++ 20でもまだ必要ですか?

  13. 13

    Array.prototype.slice.call(array、0)の用途は何ですか?

  14. 14

    Array(0)とarray = []の違いは何ですか

  15. 15

    FMDB and index 0 beyond bounds for empty array

  16. 16

    index = 0の場合のXMVectorSetByIndexとXMVectorSetXの違いは何ですか?

  17. 17

    このステートメントの背後にあるロジックは何ですか:for(-index; index> = 0; --index)?

  18. 18

    array.sliceのコンテキストでのMath.maxの目的は何ですか

  19. 19

    `[index:number]:string;`内の `index`の必要性は何ですか

  20. 20

    長さ0の配列(またはstd :: array)の用途は何ですか?

  21. 21

    Index Array without Elements

  22. 22

    Index Array without Elements

  23. 23

    Sort multidimensional array by index

  24. 24

    SwiftUI - Indexset to index in array

  25. 25

    array index out of bound

  26. 26

    Get non-repeating index from array fails on 0

  27. 27

    の実装は何ですか:+(instancetype)array;

  28. 28

    「int mask =〜0;」の目的は何ですか?

  29. 29

    varchar(0)の目的は何ですか

ホットタグ

アーカイブ