top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

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

0 votes
66 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 Google+ Share Button LinkedIn Share Button Multiple Social 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?

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...