Arrays of Structures To display any kind of bills for several customers, we need several structures. In such cases, array of structures will be useful to us. We can declare arrays of structures like this: Here, we have declared 50 structure variables starting from st[0] to st[49]. In this, st[0] represents the first customer’s electricity […]
Continue readingStructure Pointer A structure pointer is a pointer that refers to the structure. Once the structure pointer is declared, we can use ‘structure pointer member operator’ or ‘arrow operator’ to access the elements of the structure. Structure pointer member operator is represented by arrow symbol, as ->. Program to print electricity bill using a structure […]
Continue readingStructures in C A Structure is declared using the key word ‘struct’ and after that we should write the structure name, i.e store. Within the left and right curly braces, we should declare the elements that consist of the structure. Once the structure is declared as shown in below, we can declare variables of the […]
Continue readingAdvantages – Advantages and Disadvantages of Pointers Disadvantages – Advantages and Disadvantages of Pointers
Continue readingPointer to pointer We can also create a pointer to another pointer. We can declare an int type pointer and store the address of var in that variable, as: We can declare another pointer p2 to this pointer p1, as Now, this pointer can be used to store the address of the pointer p1,as: Since, […]
Continue readingWhen we declare a pointer, the size of the pointer will be determined by the memory model used while installing the Turbo C/ C++ compiler software. Program to know the default size of a pointer Output:
Continue readingGeneric Pointers A void pointer is a pointer that can be converted into any type of pointer. It is also called generic pointer. A void pointer is declared using the key word ‘void’. Once declared, it can refer to any other type of pointer, may it be char pointer, int pointer or float pointer. Program […]
Continue readingNear, far and huge pointers A near pointer is a pointer that can access only the data segment, but not other segments of memory. That is, near pointer cannot access beyond the data segment like text video memory. Size of a near pointer is 2 bytes. We use ‘near’ key word to make a pointer […]
Continue readingDangling pointer When a pointer is referencing the memory address of an invalid object, it is called a ‘dangling pointer‘. When this function is called,memory is allocated for the variable x on the stack and the pointer p containts the address of that variable x. But when the function returns control to the calling function, […]
Continue readingCallback Mechanism in C Calling a function by passing another function’s address is called a callback mechanism. To pass the address of the function, we can use a function pointer. In above statement the function is returning ‘float’ type result and accepting float type sales amount. To call the above function we can write another […]
Continue reading