int strlength(const char *myStr){
//variable used for str length counter
int strlength = 0;
//loop through string until end is reached. Each iteration adds one to the string length
while (myStr[strlength] != '\0'){
putchar(myStr[strlength]);
strlength++;
}
return strlength;
}
Why will this not work as intended? I just want to find the length of a string.
printf(" %d", mySte[strlength]);so you can see exactly what's being processed. But the code should produce 5 for "hello". Are you sure you're testing what is written in the question?