Can any one tell me how to check if the elements of two arrays are same? in c
Prithvi.R.K
0
Newbie Poster
Recommended Answers
Jump to PostSeeing as in this post you just copy/pasted from wiki answers, I suggest that you study and learn from what you posted. Once you do that, there'll be no reason to ask …
Jump to Postyou can also do it without a loop by calling memcmp(), which compares two arrays byte-by-byte.
int a[] = {1,2,3,4,5}; int b[] = {1,2,3,4,5}; if( memcmp(a,b,sizeof(a)) == 0) { printf("They are the same\n"); } else { printf("They are different\n"); }
All 7 Replies
nullptr
167
Occasional Poster
Learner010
99
Posting Whiz in Training
Prithvi.R.K
0
Newbie Poster
Learner010
99
Posting Whiz in Training
Nishali
0
Newbie Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Assembly Guy
commented:
Ahh the simple solution. Awesome
+5
Prithvi.R.K
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.