我创建的这个函数有问题,该函数应该返回数组中输入的字符数。但总是返回 20,它是数组本身的限制。
代码:
int LongitudCadena (char *pcadena) {
// cantidad its the counter of chars that in the array
int cantidad=0;
//M its a constant equals 20, that its the limit of the array
for(int a=0;a<M;a++){
if(pcadena!=0){
pcadena++;
cantidad++;
} else {
return 0;
}
}
return cantidad;
}