pointer as a parameter -
i have problem function created, function should return number of characters entered in array. return 20 limit of array itself.
code:
int longitudcadena (char *pcadena) { // cantidad counter of chars in array int cantidad=0; //m constant equals 20, limit of array for(int a=0;a<m;a++){ if(pcadena!=0){ pcadena++; cantidad++; } else { return 0; } } return cantidad; }
replace if(pcadena!=0)
if(*pcadena!='\0')
.
also, change else
condition either
else { return cantidad; }
or
else { break; }
Comments
Post a Comment