top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to calculate string length without using string function and Loop in c?

0 votes
600 views
How to calculate string length without using string function and Loop in c?
posted May 2, 2017 by Alok Kumar

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

0 votes
#include<stdio.h>
main()
{
        char str[100];
        printf("Enter a string\n");
        scanf("%[^\n]",str);
        int i=0;
        for(;str[i];i++);
        printf("Length is %d\n",i);
}
answer May 10, 2017 by Chirag Gangdev
–1 vote

//Lets check the below program

include <stdio.h>   
int main()
{
  char str[100];
  printf("Enter a string: ");
  printf( "\rLength is: %d", printf("Entered string is: %s\n", gets(str)) - 20);
  return 0;
}
answer May 9, 2017 by Raju Raj
Similar Questions
+1 vote

Consider an implementation of Strings consisting of an array where the first element of the array indicates the length of the String and the next elements represent the value of the ASCII characters in the String.
Implement String concatenation of such scenario using C?

...