Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7411599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:24:39+00:00 2026-05-29T06:24:39+00:00

I want a user defined function which is equivalent to strlen() function in C.

  • 0

I want a user defined function which is equivalent to strlen() function in C. In the below program it does the same function as strlen() but it has a limit to it. How can I make it count any length of text.

#include <stdio.h>
#include <conio.h>
void main()
{
    int len(char *);
    char s[20];
    int l;
    printf("Enter a string: ");
    gets(s);
    l=len(s);
    printf("length of string is =%d",l);
    getch();
}

int len(char *t)
{
    int count=0;
    while(*t!='\0')
    {
        count++;
        t++;
    }
    return(count);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T06:24:40+00:00Added an answer on May 29, 2026 at 6:24 am

    I think your “limit” is because you use gets() on a buffer of 20 bytes. You will experience issues due to a buffer overflow. Exactly what happens when you do that is not entirely predictable.

    If you fix that, I think your function will work as you expect it to. (Read the other people’s answers for insight on your length function.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to erase user-defined function? My CMS has one function, which I
Hey there, I want to evaluate a mathematical function (user-defined) which returns several values
I want to write a User-Defined function in SQL SERVER which will take a
Most systems will have a user-defined function (UDF) available. Some will not. i want
I have a stored procedure in which i want to create a user defined
I have a user defined function which is used in many stored procedures which
I need to write a TSQL user defined function which will accept a string
I want to create a Function in my C# code, which can be called
I want to use a case statement in my user-defined functions because I need
I have a user-defined table type. I want to check it's existence before editing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.