strlen without strlen

  #include<stdio.h>




int main(){


    // char str[] = "Harry";

    int counter;


    char str[] = {'S', 'a', 'y', 'a', 'n', '\0'};


    char *ptr = str;


    while(*ptr!='\0'){


        printf("%c", *ptr);


        ptr++;

        counter = counter +1 ;


    }

    printf("\nLenght of string is %d",counter);


    return 0;


}

Comments

Popular posts from this blog

Sum of Even Numbers till N

Find the Runner-Up Score!

Print All Substrings