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

  • Home
  • SEARCH
  • 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 8719905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:54:38+00:00 2026-06-13T06:54:38+00:00

I have an array to filter. Example: str = hellothere and filter = eo

  • 0

I have an array to filter.

Example:

str = "hellothere" and filter = "eo". What to do when i need to filter?

void filter_str(char* str, char* filter, char*result)
{
  while(*str)
  {
       if() //If the current character in str is one to be filter. 
        {
                 *str++;
        }
        else
        {
                *result++ = *str++;
        }

 } 
 *result = '\0';
}

I just can’t figure out how to check if the current character is one that needs to be filter. Since the filter can be more than one character, such as “eo”. How do I check both “e” and “o” every loop, and then reset filter back to “e” at the start.

I wanted to make a pointer to the start of filter, then use that at the end of the while to go back to the start of filter. But I am not sure how to make it check *str against all the characters to be filtered.

  • 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-06-13T06:54:39+00:00Added an answer on June 13, 2026 at 6:54 am

    In this case a function has already been written that will do the hard work for you

    if (strchr(filter, *str))
    

    In general this is the answer to any question where you have processing that is too complex for you to handle. Write a function to solve the ‘inner’ problem, and then use that function in the ‘outer’ problem. In this case the inner problem is finding a character in a string, and the outer problem is the filtering operation you are doing. You are just lucky that the inner problem has already been solved for you.

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

Sidebar

Related Questions

I have an array of objects with different properties and I need to filter
I have a simple model object with one array property. Example: {name: 'Foo', tags
I have one master array and multi slave arrays and i need function that
I have an array: string myArray={15,56,17-75,78,100-150,130} I want to filter myList by arrayElements .
I have to filter out certain elements from an array in javascript and thought
I have these code in my views.py: array = [] p = Person.objects.filter(client=1,status='Complete').values('name', 'age',
I have an IEnumerable<DirectoryInfo> that I want to filter down using an array of
I have array result like this: Array ( [0] => stdClass Object ( [id_global_info]
I have a mutable array of custom objects. I want to filter that array
I have an array with default settings, and one array with user-specified settings. I

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.