Software > Software

comparing arrays, easy one but im a student, C++

<< < (2/2)

snow:
Noob or not... that is the only way you can compare two arrays. In loop of somekind (for, while, do-while).

Simple stuff like loops, conditionals, arrays are the same in C and C++.

From wikipedia:

--- Quote ---Compared to the C language, C++ introduced extra features, including declarations as statements, function-like casts, new/delete, bool, reference types, inline functions, default arguments, function and operator overloading, namespaces and the scope resolution (::) operator, classes (including all class-related features such as inheritance, member functions, virtual functions, abstract classes, and constructors), templates, exception handling, runtime type identification, and the overloaded input (>>) and output (<<) operators for input and output respectively.
--- End quote ---

So as long you dont use this stuff in C++ you basicly have C :)

rgcustodio:
Further analysis of an array (based on the specifications) shows that these are allocated as a contiguous memory area.
A loop is OK, but as I've previously mentioned, a memcmp will work as efficiently.
Less code to write in fact, and as always less is always more.


--- Quote from: snow on September 21, 2007, 02:21:25 AM ---Noob or not... that is the only way you can compare two arrays. In loop of somekind (for, while, do-while).

--- End quote ---

Navigation

[0] Message Index

[*] Previous page

Go to full version