==> STRINGS--
==> POINTERS--
Declaration :
data_type *variable_name;
Ex : int *a;
Ex :
#include int main()
{
int var = 20;
int *ip;
ip=&var;
printf(“Address of variable is %x ”, &var);
printf(“Address stored in ip variable is :%x”,ip);
printf(“value of *ip variable : %d”, *ip);
return 0;
}
==> One Dimensional Array---
Declaration::
Syntax: data_type array_name[array_size];
where, data_type can be int, float or char.
array_name is the name of the array.
array_size indicates number of elements in the array.
For ex: int age[5];
Initialization::
Syntax: data_type array_name[array_size]={v1,v2,v3};
where, v1, v2, v3 are the values
For ex: int age[5]={2,4,34,25,18};
==> Two Dimensional Array----
Declaration::
Syntax: data_type array_name[array_size][array_size];
where, first index shows the row number of the element and
second index shows the coulmn number of the element
Initialisation::
Syntax: data_type array_name[array_size][array_size]={V1,V2,V3,.....Vn};
where, V1, V2, V3,......,Vn are the values
For ex: int matrix[2][3]={2,4,56,3,6};
DYNAMIC MEMORY ALLOCATION----
FUNCTIONS OF DYNAMIC MEMORY ALLOCATION----
=> malloc() – It allocates requested size of bytes and returns a pointer first byte of allocated space.
Syntax : ptr=(data_type *)malloc(bysize);
Ex : (int*)malloc(100*sizeof(int))
=> calloc() – Allocates spaces for array elements, initializes to zero and then returns a pointer to memory.
Syntax : ptr=(data_type*)calloc(n,element_size);
Ex : ptr=(float*)calloc(25,sizeof(float))
=> realloc() – Changes the size of the previously allocated space according to the requirement.
Syntax : ptr=realloc(ptr,newsize);
=> free() – It deallocates the previously allocated space.
Syntax – free(ptr);
Jump to Page : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53