1、问题如题目。按理说应该报错的是吧?可是我用valgrind运行都没有显示错误,请大佬帮忙解释啊~
2、代码如下:
#include <stdio.h>
int main(int argc, char *argv[])
{
int numbers[4] = {5};
char name[4] = {'a', 'a', 'a', 'a'};
printf("name: %s\n", name);
}
结果输出正常:
==26627== Memcheck, a memory error detector
==26627== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==26627== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info
==26627== Command: ./ex9_1
==26627==
name: aaaa
==26627==
==26627== HEAP SUMMARY:
==26627== in use at exit: 0 bytes in 0 blocks
==26627== total heap usage: 1 allocs, 1 frees, 1,024 bytes allocated
==26627==
==26627== All heap blocks were freed -- no leaks are possible
==26627==
==26627== For lists of detected and suppressed errors, rerun with: -s
==26627== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)