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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:30:52+00:00 2026-06-11T15:30:52+00:00

The snippets below are from my program that gets words, then prints them with

  • 0

The snippets below are from my program that gets words, then prints them with the number of occurences.

It works almost fine except for it “forgots” that particular entry has been saved before and does NOT increment counter associated with it.

typedef struct {
    char *word;
    int occ;
}
words;
words *data=NULL;

int main(int argc, char **argv)
{
    char *word;
    words *temp;
    int c,i,num;
    words *ptr = NULL;

    num=0;

    while(1)
    {
        c=fgetc(infile);
        if(c==EOF) break;
        if(!isalpha(c)) continue;
        else ungetc(c,infile);
        word=getword(infile);

        if(findword(word))
        {

            if(!(temp=realloc(data,sizeof(words)*(num+1))))
            { /* error handling */ }
            else
                data=temp;



        }
        else
           free(word);
    }

    /* sort procedure here, irrelevant for the purpose of topic */
    for(i=0;i<num;i++)
    {
        /*printf*/
    }

    return 0;

}

What’s wrong with that code?

Thanks in advance!

  • 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-11T15:30:53+00:00Added an answer on June 11, 2026 at 3:30 pm

    The fundamental problem is that your “findword” function isn’t actually finding a word; it’s just looking at one item in the list. It needs to loop.

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

Sidebar

Related Questions

Below is a function from a program: //read the specified file and check for
From the below code one can discern that the function menu is called with
I'm working a program that is pulling a string field from an access database,
Why do the code snippets below, taken from this article , produce different results
In the code snippet below, from my jQuery setup, I need to check if
Using the snippet below, I've attempted to extract the text data from this PDF
Validation in Spring 3.x using @Valid annotation: Below is snippet from the messages_en.properties. I
I am using the below code snippet to FTP simple text files from a
I am very new to asp classic application. The below code snippet is from
Below is a code snippet from a book. Why can serialNumber still be set

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.