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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:59:30+00:00 2026-05-28T18:59:30+00:00

I am getting the following error from valgrind. Conditional jump or move depends on

  • 0

I am getting the following error from valgrind. Conditional jump or move depends on uninitalized values. I have looked around at similar questions but I am not able to find out whats wrong. I have initialized all the variables, but still..

unsigned long hash_word(const char *str)
 {
  unsigned long hash = 5381;
  int c = 0;

  while((c = *str)) // The error occurs here
   {
    hash = ((hash<<5) + hash) + c;
    str++;
   }

 return hash%1999099;
}

The value of str is passed from the main function. I am using leak-check=full and track-origins=yes. Thanks in advance for the help.

First I am initializing a node.

    typedef struct node{
     char word[46];
     struct node *next;
  } node;

The calling code is

  while(!(feof(fp)))
 {
   node *n =  malloc(sizeof(node));
   if (n == NULL)
    {
     return false;
    }
   else
    {
     fscanf(fp,"%s",n->word);

     index = hash_word(n->word);
     .
     .
     .    // further code
   }
  • 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-28T18:59:31+00:00Added an answer on May 28, 2026 at 6:59 pm

    This looks like a misunderstanding in what feof() does. It doesn’t return a true value until after a read has failed due to EOF. Therefore, in your last iteration, the fscanf() call fails and thus does not initialize n->word. You should check the return value of fscanf(). If it hits EOF it returns the C value EOF. You could also check for the value 1 indicating a single field was successfully converted.

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

Sidebar

Related Questions

Hi I am getting the the following error from valgrind. Conditional move based on
I have downloaded a web project from CodePlex and am getting the following error
I am getting the following error when I post back a page from the
I'm getting the following error whenever my code creates a DataTableReader from a valid
I am getting the following error when trying to update my project from Intellij
I am getting a compile error from the following property. The error is: The
I'm getting the error message when running the following code from a C# console
I am getting the following error from some users while performing a lightweight Core
I am getting the following error from C++ Builder 2009's linker Unresolved external '__fastcall
I'm getting the following error from g++ while trying to add iterator support for

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.