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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:03:04+00:00 2026-06-02T08:03:04+00:00

I’m working on a program for my Intro to C class that requires me

  • 0

I’m working on a program for my Intro to C class that requires me to write a program that solves jumble puzzles (you know, those anagram puzzles you see in the newspaper), based on a dictionary text file that my professor gave us. It alphabetizes words from the dictionary, takes in jumbles from a text file (called “jumble.txt”), alphabetizes those, then runs a string compare to find a match. I’ve got all the code written, but it immediately crashes when I try to run it, and I can’t figure out why. I thought maybe the Stackoverflow users might be able to help me out here.

Here’s the code I have:

#include <stdio.h>
#include <strings.h>
#define MAX_WORD_LEN 6
#define MAX_NUM_WORDS 30000

typedef struct {
    char word[MAX_WORD_LEN+1];
    char sort[MAX_WORD_LEN+1];
} jumble_type;

void bubblesort(char letters[], int length);


int main () {
    int words, jumbles;
    int j, q;
    jumble_type list[MAX_NUM_WORDS];
    jumble_type list2[MAX_NUM_WORDS];


// Creating file pointers
FILE *ifp;
FILE *ifp2;

//Opens Jumble and dictionary files and reads the info from them
ifp = fopen("jumbledct.txt", "r");
ifp2 = fopen("jumble.txt", "r");

//Assigns the value of "words" to the first line of jumbledct.txt
fscanf(ifp, "%d", words);

//Assigns the value of "jumbles" to the first line of jumble.txt
fscanf(ifp2, "%d", jumbles);

// Reads the words from the dictionary into the "word" section of our
// list structure.
int i;
for (i = 0; i < words; i++){
    fscanf(ifp, "%s", &list[i].word);
    strcpy(list[i].sort, list[i].word);
    bubblesort(list[i].sort, strlen(list[i].sort));
    printf("%s\n", list[i].sort);
    }

//Reads from Jumble.txt
for (i = 0; i < jumbles; i++){
    fscanf (ifp2, "%s", &list2[i].word);
    strcpy(list2[i].sort, list2[i].word);
    bubblesort(list2[i].sort, strlen(list2[i].sort));
    //printf("%s\n", list2[i].sort);
    }

for(j=0;j<jumbles; j++){
        printf("JUMBLE PUZZLE # %d: %s\n", j+1, list2[j].word);


    int x=0;

for (q = 0; q < words; q++){



        if(strcmp(list2[j].sort, list[q].sort)==0){

            printf("%s\n", list[q].word);
            x++;
        }
}
 if (x == 0){
            printf("Sorry, this puzzle has no solutions. \n\n");
        }
        printf("\n");

}


return 0;
}

void bubblesort(char letters[], int length) {
char temp;
    int x, y;
    for(x = 0; x < length; x++){
        for (y = x; y < length; y++){
            if (letters[x] > letters[y]){
                temp = letters[y];
                letters[y] = letters[x];
            letters[x] = temp;
        }
    }
}
}

Thanks in advance for all your help.

  • 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-02T08:03:05+00:00Added an answer on June 2, 2026 at 8:03 am

    My C is a little rusty, but shouldn’t the third argument to the fscanf function be an address (like &words and &jumbles)?

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

Sidebar

Related Questions

I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
Does anyone know how can I replace this 2 symbol below from the string
I need a function that will clean a strings' special characters. I do NOT

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.