Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to compare & verify that two structures are equal in

Status
Not open for further replies.

UroBoros

Advanced Member level 2
Joined
May 5, 2004
Messages
642
Helped
19
Reputation
38
Reaction score
8
Trophy points
1,298
Location
Cochin - India
Activity points
6,463
Simple 'C 'doubt!

Hai
How can we compare and verify that two structures are equal in C ,Especially in CCS C .

if(realtime==shedule1[0])
{
}

this is giving error. (neumeric expression required)
both are structure variables of same type.

Sorry i am not a 'C' expert !

Picstudent
 

Simple 'C 'doubt!

Sorry, see question 2.8 in the C FAQ:
https://www.eskimo.com/~scs/C-faq/q2.8.html

If you enjoy living dangerously, and have intimate knowledge of your compiler's memory allocation, then you may be able to use a memory compare function such as memcmp(). But beware of non-portability issues.

As you learn C, you will have many questions. This FAQ is a great resource!
 

    UroBoros

    Points: 2
    Helpful Answer Positive Rating
Simple 'C 'doubt!

Did not check for errors , but should work OK :


typedef struct {
int a;
char b;
float c;
dluble d;
...'
} mystruct;





comparestruct (mystruct *struct1_p, mystruct *struct2_p)
{
char *p1_p, *p2_p;
int k = sizeof(mystruct);

p1_p = (char *)struct1_p;
p2_p = (char *)struct2_p;
for (;k!=0;k--)
if(*p1_p++ != *p2_p++)
return -1;

return 0;
}
 

    UroBoros

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top