Showing posts with label Calculate Length of String without Using strlen() Function. Show all posts
Showing posts with label Calculate Length of String without Using strlen() Function. Show all posts

Wednesday, 6 June 2018

Calculate Length of String without Using strlen() Function

#include <stdio.h>
void main()
{
    char s[1000], i;
    clrscr();
    printf("Enter a string: ");
    scanf("%s", s);

    for(i = 0; s[i] != '\0'; ++i);

    printf("Length of string: %d", i);
    getch();
}