Mar 20, 2014 - C/C++, Programming    No Comments

Structures, Nested Structures, Pointer to structures C++

Structures, Nested Structures, Pointer to structures C++, array is a collection of elements of same datatype, so to store elements of different data types we need structure. Structure is a collection of elements of different data types. The data elements of structure are referred to as members.

Here is a very much self explanatory code for structures

#include
#include
using namespace std;
Continue reading “Structures, Nested Structures, Pointer to structures C++” »

Mar 20, 2014 - C/C++, Programming    No Comments

Dynamic Memory Allocation using malloc, calloc, realloc

Dynamic memory allocation using malloc, calloc, realloc. Dynamic memory allocation is used to allocate the memory according to need during runtime. For example we have a program which has variable need of memory, now if we statically allocate its memory then either the allocated memory could be insufficient or their may be the possibility of fragmentation of memory, both the cases will be unfavorable to the program. So we adopt the use of dynamic memory allocation.
Continue reading “Dynamic Memory Allocation using malloc, calloc, realloc” »

Mar 19, 2014 - C/C++, Programming    No Comments

Passing array to function and parameters of function using array C++

Passing array to function and what should be the parameters of the function in which the array is passed.?
In the below code i have described two functions “printarr” and “printarr2″ both incrementing the values of the element by one and then printing them.
In the function call we have passed identical values, first one s the starting address of the array (address of the first element of the array) and the second one is the length of the array.

Continue reading “Passing array to function and parameters of function using array C++” »

Pages:123»
UA-33384550-1