Find the length of the string using while loop

Given a string find the length of the string without using library function and using while loop to traverse the string.



#include <stdio.h>
int main(void) {
   char *s;
   int len=0;
   
   /* Allocate the memory for the input string */
 s=(char*)malloc(sizeof(char));
    
    /* Get the input string from the user */
  scanf("%s",s);
 
 /* While the pointer doesn't reach the null character which has the macro constant "0" value */
  while(*s)
    
     /* Increment the length of the character & the pointer to the character */
   len++,s++;
    
    /* Print the length of the string */
  printf("length of %s is %d",(s-len),len);
   return 0;
}