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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:06:38+00:00 2026-06-11T09:06:38+00:00

I am attempting to check string letters against another let of letters, checking the

  • 0

I am attempting to check string letters against another let of letters, checking the first letter in userword[k] against all the letters in letterstest[t] and if they match switching that matching letter of letterstest[t] with 0 so it cannot be matched again. Where I am confused on is inside the switch(){ and what exactly would work. Is there a case: what can switch the letters of the strings?

for (k = 0; k<wordsize; k++){
    for(t=0; t<8, t++){
        if (userword[k] != letterstest[t]) 
            return 0;

        if (userword[k] == letterstest[t]){    
            switch (letterstest[t]){

                    //unsure what case would work here
            }
        }
    }
}
  • 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-11T09:06:39+00:00Added an answer on June 11, 2026 at 9:06 am

    I think you’re misunderstanding what switch is. switch is a selection structure, like if/else. For example, these two code-snippets are (generally) equivalent:

    if(a == 0)
        printf("%s\n", "zero");
    else if(a == 1)
        printf("%s\n", "one");
    else if(a == 2)
        printf("%s\n", "two");
    else
        printf("%s\n", "invalid");
    
    switch(a)
    {
        case 0:
            printf("%s\n", "zero");
            break;
        case 1:
            printf("%s\n", "one");
            break;
        case 2:
            printf("%s\n", "two");
            break;
        default:
            printf("%s\n", "invalid");
    }
    

    I’m not completely clear on what you’re trying to do, but when you write “if they match switching that matching letter of letterstest[t] with 0 so it cannot be matched again”, it sounds like you mean this:

        if (userword[k] == letterstest[t]){
            letterstest[t] = '\0';
        }
    

    Edited to add: O.K., I think I now understand what you’re trying to do:

    • you want to confirm that every character between userword[0] and userword[wordsize-1] appears somewhere between letterstest[0] and letterstest[7].
    • if a given character appears multiple times between userword[0] and userword[wordsize-1], then it must appear at least as many times between letterstest[0] and letterstest[7]. That is — a character between letterstest[0] and letterstest[7] can only count once.
    • you’re O.K. with changing what characters appear between letterstest[0] and letterstest[7], as long as the final answer is correct; that is, you don’t need to preserve the contents of letterstest.
    • the character '\0' does not occur anywhere between userword[0] and userword[wordsize-1], so can be used as a “dummy” value meaning “not a match”.

    Is that correct?

    If so, then you can write:

    for(k = 0; k < wordsize; k++) {
        for(t = 0; t < 8; t++) {
            if(userword[k] == letterstest[t]) {
                letterstest[t] = '\0'; /* don't let letterstest[t] count again */
                break; /* O.K., we've matched userword[k], we can move on */
            }
        }
        if(t == 8) /* we reached letterstest[8] without finding a match */
            return 0;
    }
    return 1; /* we found a match for each character */
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to check if a string(filter) is contained in another string(formattedAmount) i.e. is
I am attempting to check to see if a string is a palindrome. Example:
I'm attempting to remove accents from characters in PHP string as the first step
I am attempting to check if a given user has a role before they
When attempting to check the 'content-length' header for some web pages using urllib2 in
I'm attempting to check if a value exists in the choices tuple set for
How can I check for the existence of an aspx page before attempting to
I have a C# application that I am attempting to check my sqlite db
I am attempting to simply check a list of Managed Properties for a specific
I am attempting to build a function as to check wether or not wild

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.