Test 1

From CDOT Wiki
Jump to: navigation, search
  • Q1. When moving though an array we use the size to move through byte by byte but when we pass two values or a value we are able to do 'value++'. Why in example 1 we use size and in example 2 we use '++', when both are .

Example 1.

n = sum(a, 11, sizeof(int), isEven, &e); // Where a is an array
int sum(void* x, int n, int size, bool (*f)(void*, void*), void* result)
ptrcharx = ptrcharx + size;

Example 2.

b = exchange(&x, &y, sizeof(int), (int(*)(void *, void *))ig); // x =4, y =3
int exchange(void *a, void *b, int n, int(*f)(void *, void*))
a1 = (char*)a;