C Write To Files
Write To a File Let’s use the w mode from the previous chapter again, and write something to the file we just created. The w mode means that the file is opened for writing. To insert content to it, you…
Write To a File Let’s use the w mode from the previous chapter again, and write something to the file we just created. The w mode means that the file is opened for writing. To insert content to it, you…
File Handling In C, you can create, open, read, and write to files by declaring a pointer of type FILE, and use the fopen() function: FILE *fptr; fptr = fopen(filename, mode); FILE is basically a data type, and we need…
Math Functions There is also a list of math functions available, that allows you to perform mathematical tasks on numbers. To use them, you must include the math.h header file in your program: #include <math.h>
Recursion Recursion is the technique of making a function call itself. This technique provides a way to break complicated problems down into simple problems which are easier to solve. Recursion may be a bit difficult to understand. The best way…
Function Declaration and Definition You have already learned from the previous chapters that you can create and call a function in the following way: Example // Create a function void myFunction() { printf(“I just got executed!”); } int main()…
Now that you understand how functions work, it is important to learn how variables act inside and outside of functions. In C, variables are only accessible inside the region they are created. This is called scope.
Parameters and Arguments Information can be passed to functions as a parameter. Parameters act as variables inside the function. Parameters are specified after the function name, inside the parentheses. You can add as many parameters as you want, just separate…
A function is a block of code which only runs when it is called. You can pass data, known as parameters, into a function. Functions are used to perform certain actions, and they are important for reusing code: Define the…
Pointers & Arrays You can also use pointers to access arrays. Consider the following array of integers: Example int myNumbers[4] = {25, 50, 75, 100}; You learned from the arrays article that you can loop through the array elements with…