top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Why we cannot compare two same type of structure?

+6 votes
333 views
Why we cannot compare two same type of structure?
posted Apr 6, 2016 by Mohammed Hussain

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

As far as I know, In C language comparison operator == works with predefined datatypes.
Structure is a user defined data type that's why == does not work.
Assume one structure is defined named as "A".
Now I created two variables of structure A such as var1 and var2
Better to use memory comparison memcmp(&var1, &var2, sizeof(A)) to compare user defined data types.

answer Apr 6, 2016 by Harshita
Similar Questions
+1 vote

Two tables from two different databases are there . both having same structure but different data . how to compare these two tables ?

+2 votes

Provide an algorithm to add and multiply two large integers which cannot be represented by built-in types, C code would be a great help?

0 votes

Say
float i = 1.1;
float j = 1.1;

Many a time if (i == j) results in false. Why??

...