Tag Archives: cpp-array

Array Type Manipulation in C++

This article demonstrates some of the inbuilt functions that can be used to query and manipulate array types, even a multidimensional array. These functions can be useful in cases we need information or manipulate array we initiated with different dimensions. These functions are defined in header file . Some of the functions include : is_array()… Read More »

How to return a local array from a C/C++ function?

Consider the below C++ program. Is it right way of returning array from a function? In function ‘int* fun()’: 6:8: warning: address of local variable ‘arr’ returned [-Wreturn-local-addr] int arr[100]; ^ The above program is WRONG. It may produce values 10 20 as output or may produce garbage values or may crash. The problem is,… Read More »

Interesting Facts in C Programming

Below are some interesting facts about C programming: 1) The case labels of a switch statement can occur inside if-else statements. Output : GeeksforGeeks 2) arr[index] is same as index[arr] The reason for this to work is, array elements are accessed using pointer arithmetic. Output : 1 3) We can use ‘<:, :>’ in place… Read More »

Array class in C++

The introduction of array class from C++11 has offered a better alternative for C-style arrays. The advantages of array class over C-style array are :- Array classes knows its own size, whereas C-style arrays lack this property. So when passing to functions, we don’t need to pass size of Array as a separate parameter. With… Read More »