The code below does not print anything –
int main() {
char *input = "This is a string";
find_length(input);
return 0;
}
void find_length(char *input){
printf("%s", input);
int length = 0;
while(input[length]!='\0');
{
length++;
printf("%i", length);
}
}
You have an extra semicolon behind your loop:
So it is stuck in an infinite loop. Get rid of it.
Furthermore, there could be stream buffering. Try adding some
\n. Or callfflush(stdout)to flush the output stream.