Source Code to Print out the Length of a String in C Programming
The following source code will print out the length of a string in C Programming
#include <stdio.h>
main()
{ char s[81];
printf("Enter string: ");
scanf("%s", s);
printf("length = %d\n", len(s));
}
int len(char s[])
{ if(*s)
return 1+len(++s);
return 0;
}
Related Articles
- Printing Hello World and Numbers From 1 to 11 in C Programming
- Source Code for Math Functions Sin Cos Tan ArcTan Absolute Value in C Programming
- Source Code for Math Functions Log10 Floor Round Power Square Root in C Programming
- Source Code for Calculating Factorial of a Number using a For Loop in C Programming
- Source Code for Calculating Factorial of a Number using a DO WHILE Loop in C Programming
- Source Code for Calculating Factorial of a Number using a Recursive Function in C Programming
- Source Code for Calculating Factorial of a Number using a WHILE Loop in C Programming
- Source Code to Change any Number in Base 10 to Base 2 or Binary in C Programming
