Why do C and C++ compilers allow array lengths in function signatures when they're never enforced?

后端 未结 10 1411
终归单人心
终归单人心 2020-11-22 06:59

This is what I found during my learning period:

#include
using namespace std;
int dis(char a[1])
{
    int length = strlen(a);
    char c = a         


        
10条回答
  •  清酒与你
    2020-11-22 07:42

    It's allowed for compilers to be able to check whether the size of array passed is the same as what expected. Compilers may warn an issue if it's not the case.

提交回复
热议问题