Find the sum of all the digits of a string using library function

Given a string which consists of only numbers , find the sum of the numbers of the string using library function.


#include <stdio.h>
#include <string.h>
#include <stdlib.h>

/* Typedef unsigned long long int datatype using ll keyword */
typedef unsigned long long int ll;

int main(void) {

   char *s;

    /* Declare variables n and sum as unsigned long long int */
  ll n,sum=0;

    /* Dynamically allocate the memory for the input string */
  s=(char*)malloc(sizeof(char)*256);

    /* Get the input string from the user */
  scanf("%s",s);

    /* Convert the string to integer using library function "atoi" */
  n=atoi(s);

    /* Calculate sum of the individual digits of number */
  for(sum+=(n%10);n!=0;n=n/10,sum+=(n%10));

    /* Print the sum of the digits of the string */
  printf("the sum of the digits of %s is %llu",s,sum);

  return 0;

}