Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Comparing Two Arrays in C: By Contents and By Address

Comparing Two Arrays in C: By Contents and By Address

This C program compares two distinct arrays and if the arrays are same then content results in FALSE. The behavior of comparison is explained when we note that the comparison is a comparison of addresses, not contents.

Elon Musk
Discover the mind behind the innovations – Elon Musk by Walter Isaacson, now on Audible. Dive into the life of a visionary shaping our future!
View on Amazon

Comparing Arrays by Addresses

Comparing Arrays by Addresses

In this updated code, we added a loop to compare each element of arrays a and b. If any pair of corresponding elements is not equal, the equal variable is set to 0, indicating that the arrays are not equal. The result is then printed based on the value of the equal variable.

About The Author

M. Saqib

Saqib is Master-level Senior Software Engineer with over 14 years of experience in designing and developing large-scale software and web applications. He has more than eight years experience of leading software development teams. Saqib provides consultancy to develop software systems and web services for Fortune 500 companies. He has hands-on experience in C/C++ Java, JavaScript, PHP and .NET Technologies. Saqib owns and write contents on mycplus.com since 2004.