Function Pointers A function pointer is a pointer that stores the memory address of a function. Any function will also have an address, and the function address is represented by the function name. Function pointers allow user to pass functions as pointers to other functions. Here, ‘sum’ is the function name. Since the function name […]
Continue readingArrays of Pointers in C When we want to allocate dynamic memory to group of variables, strings or arrays, we need group of pointers. In such a case, we can declare array of pointers. In such a case, we can declare array of pointers. To allocate dynamic memory for 50 strings, we can declare 50 […]
Continue readingDynamic Memory Dynamic memory is the memory allotted by the programmer at runtime. The size of the dynamic memory grows at runtime and its very huge memory. malloc() This function is useful to allocate required number of bytes on heap memory. This function is defined in the header files <alloc.h> and <stdlib.h>. In unix we […]
Continue readingpointers in c A pointer is a variable that stores the memory address of another variable. To declare a pointer, we should write a star (*) symbol before the variable and declare it as: Thus when * symbol is used before the variable, the computer will be able to understand that it is not an […]
Continue readingLocal Variables in C Local variable is a variable declared within a block, i.e within left and right curly braces. For example, variables declared in the function body become local variables. Also, we can create a block as: Here, ‘x’ becomes a local variable. The local variable value is limited only to that block, where […]
Continue readingExternal Storage class in C When a variable is defined at the top of all the functions in a program, it is called an external variable or global variable. To refer to that variable from a function, we should use the ‘extern’ keyword before the variable inside the function. The variables ‘auto’,’register’, or’static’ are available […]
Continue readingStorage Class in C Static variable is a variable whose value exists between function calls. It means, the static variable value will be retained even after coming out of a function, so that value can be used another function. Static variable is created on memory and initialized with default values like 0 or spaces. Program: […]
Continue readingRegister Storage Class This storage class is same as the automatic storage class, except that the variable is not stored on computer’s memory. The register variable is stored on the CPU registers. The way we can use this class is: Here, ‘num’ is the variable which is declared as belonging to ‘the ‘register’ storage class. […]
Continue readingStorage class: Storage class is a keyword that represents the location and the scope of the variable. Automatic storage class: The automatic storage class is represented by the keyword ‘auto’. So, we can declare a variable as: When a variable is declared as ‘auto’. It is created on computer’s memory. it contains some garbage or […]
Continue readingstrstr() The strstr() function returns the first character of a substring in a main string. This function starts counting the position from 0 onwards. Here, str is the main string. sub represents the sub string. When sub string is found in the main string, this function returns a character type pointer(address) of the sub string […]
Continue reading