Skip to main content
added 124 characters in body
Source Link
alciregi
  • 157
  • 1
  • 7

Why strcmp(value,curr->value) returns always 0?

I'm using a code like this:

char buffer[LENGTH+1] = {};
while(fscanf(inptr, "%s", buffer) > 0)
{
  insert( hashtable, buffer );
}

Then, inside the insert function, I use strcmp function.
Where I'm wrong?

If I use the insert function outside the while fscanf loop, it works as expected.

insert(hashtable, "aword");

Why strcmp(value,curr->value) returns always 0?

I'm using a code like this:

char buffer[LENGTH+1] = {};
while(fscanf(inptr, "%s", buffer) > 0)
{
  insert( hashtable, buffer );
}

Then, inside the insert function, I use strcmp function.
Where I'm wrong?

Why strcmp(value,curr->value) returns always 0?

I'm using a code like this:

char buffer[LENGTH+1] = {};
while(fscanf(inptr, "%s", buffer) > 0)
{
  insert( hashtable, buffer );
}

Then, inside the insert function, I use strcmp function.
Where I'm wrong?

If I use the insert function outside the while fscanf loop, it works as expected.

insert(hashtable, "aword");
Source Link
alciregi
  • 157
  • 1
  • 7

strcmp node->value

Why strcmp(value,curr->value) returns always 0?

I'm using a code like this:

char buffer[LENGTH+1] = {};
while(fscanf(inptr, "%s", buffer) > 0)
{
  insert( hashtable, buffer );
}

Then, inside the insert function, I use strcmp function.
Where I'm wrong?