Using memset for integer array in C

前端 未结 10 1721
遇见更好的自我
遇见更好的自我 2020-11-27 02:20
char str[] = \"beautiful earth\";
memset(str, \'*\', 6);
printf(\"%s\", str);

Output:
******ful earth

Like the above use of memset, can we initial

10条回答
  •  野性不改
    2020-11-27 03:01

    I tried the following program and it appears that you can initialize your array using memset() with -1 and 0 only

    #include
    #include
    
    void printArray(int arr[], int len)
    {
            int i=0;
        for(i=0; i

提交回复
热议问题