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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:55:37+00:00 2026-05-31T04:55:37+00:00

I am pretty new to C, and I thought I would try to make

  • 0

I am pretty new to C, and I thought I would try to make a program which unscrambles a string input to reveal a real word and I have it working, but with some words I get unexpected results. Here is an example of it working correctly:

Enter Word:stop

Match: opts
Match: post
Match: pots
Match: spot
Match: stop
Match: tops

I am using a word list that I got from a program called “aspell” which allowed me to create a file full of words. What’s strange is when I enter a word like “test” or “football” the response brings back words that have letters that don’t originally exist in the input word. What am I doing wrong here? The following is my unscrambleWord function, which does most of the work. Also, I will post the “football” example

int unscrambleWord(int fgLetters) {

        // integer used for the counter
        int i = 0;

        // first make sure that the lengths of the word and of the list word is the same
        if(strlen(currentLine) == strlen(input)) {

                // loop through each letter in the word given
                for(i = 0; i < strlen(input); i++) {

                        // search the line for the current letter, if we find it increment fgLetters
                        if(strchr(currentLine, input[i]) != NULL)
                                fgLetters++;

                } // end for

                // once we have finished looping through the word; evaluate fgLetters
                if(fgLetters == strlen(input)) {

                        // fgLetters will be equal to the length of the word if each letter appears in the word
                        printf("\tMatch: %s \n", currentLine);

                } // end if - evaluate length of fgLetters

        }

    // return the fgLetters after we have possibly incremented it
        return fgLetters;

}

Here is the football example:

Enter Word:football

Match: blastoff 
Match: boastful 
Match: flatboat 
Match: football 
Match: lifeboat 
Match: softball 

For some reason, there are s’s in the match strings, but the number of characters seem to be the same.

  • 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-31T04:55:38+00:00Added an answer on May 31, 2026 at 4:55 am

    This algorithm gives false positives.

    Every letter of the word football is in the word softball. But that doesn’t mean you can reorder the letters to change the word. You match the two os to the same o letter.

    An easy way to find matches is to sort the letters and see that you get the same word.

    football -> abflloot
    softball -> abfllost
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm pretty new to PHP, but I decided to try and make a simple
I am pretty new in data base design and I would like have your
I'm pretty new to sharepoint-development, so I thought I'd check real quick with the
I thought I would try and write a program that would paint a ball,
Pretty new to MVC and the like. I have a class the looks like
I have a problem which I'm pretty sure that I can't solve without going
I'm pretty new to ajax (via jQuery) and JavaScript. What I would like is
I'm pretty new to ORMs, and I'm currently giving Telerik OpenAccess ORM a try
I thought this was pretty simple, because I am pretty sure I have done
Pretty new to Perl so there may be a very obvious solution here. I'm

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.