Using memset for integer array in C

前端 未结 10 1694
遇见更好的自我
遇见更好的自我 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:19

    Short answer, NO.

    Long answer, memset sets bytes and works for characters because they are single bytes, but integers are not.

提交回复
热议问题