Find the length of the string using for loop

Given a string find the length of the string without using library function and using for loop.



#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 */
  scanf("%s",s);

    /* Until the pointer reaches end of the string, increment the length variable and pointer to character variable */
  for(;*s;len++,s++);
        /* Print the length of the string */
   printf("length of %s is %d",(s-len),len);
  return 0;

}