Write a program to find length of a string without using library functions


Write a program to find length of a string without using library functions.
  1. #include <stdio.h>
  2. void main()
  3. {
  4.     char str[100];
  5.     int i, len = 0;
  6.  
  7.     printf("Please enter a string : ");
  8.     scanf("%s", str);
  9.    
  10.     for (i = 0; str[i] != '\0'; i++) {
  11.         len++;
  12.     }
  13.     printf("The length of a string is : %s = %d\n", str, len);
  14. }


একটি মন্তব্য পোস্ট করুন