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 96817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:53:10+00:00 2026-05-10T23:53:10+00:00

At work today we were trying to come up with any reason you would

  • 0

At work today we were trying to come up with any reason you would use strspn.

I searched google code to see if it’s ever been implemented in a useful way and came up blank. I just can’t imagine a situation in which I would really need to know the length of the first segment of a string that contains only characters from another string. Any ideas?

  • 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. 2026-05-10T23:53:10+00:00Added an answer on May 10, 2026 at 11:53 pm

    Although you link to the PHP manual, the strspn() function comes from C libraries, along with strlen(), strcpy(), strcmp(), etc.

    strspn() is a convenient alternative to picking through a string character by character, testing if the characters match one of a set of values. It’s useful when writing tokenizers. The alternative to strspn() would be lots of repetitive and error-prone code like the following:

    for (p = stringbuf; *p; p++) {   if (*p == 'a' || *p == 'b' || *p = 'c' ... || *p == 'z') {     /* still parsing current token */   } } 

    Can you spot the error? 🙂

    Of course in a language with builtin support for regular expression matching, strspn() makes little sense. But when writing a rudimentary parser for a DSL in C, it’s pretty nifty.

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

Sidebar

Related Questions

Hi I have been trying this today and haven't had any luck. this stored
As we work in team today, and we use different OSes, is it possible
Today i have been interested in answers on this: where you create your work
I've been trying to get crontab to work for a while but it doesnt
Trying to select a date (x) days from today's date, where the date would
I have been trying to get a script to work on my site and
I've been trying to get my query to work for some time it runs
I've spent most of today trying to work out why the css on my
I was trying to work with it today in a scenario similar to this:
My goal is very simple today, I am trying to work out the proper

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.