In today’s C programming language tutorial we take a look at how to use time and date from C programs.
To make use of time and date function you need to include the time.h header file from the standard C library.
This header file contains functions and macros that provide standardized access to time and date. It also contains functions to manipulate and format the time and date output. The time.h reference page contains more information about the different time and date functions.
More »
Posted in C Tutorials |
In this tutorial we take another look at command line parameter parsing with C programs. In a previous command line parameter tutorial we already looked at some simple command line argument parsing example. Please read that tutorial before advancing below. More »
Posted in C Tutorials |
In a previous tutorial we already talked about renaming and removing a file. In this C programming language tutorial we look at how to copy a file.
Let’s look at an example: More »
Posted in C Tutorials |
In two previous tutorials we talked about file I/O functions on text files and file I/O functions on binary files. In this C programming language tutorial we look at how to remove files and how to rename a file. More »
Posted in C Tutorials |
In an earlier tutorial we talked about file I/O functions and the use of text files. In this C programming tutorial we are going to talk about the use of binary files.
Binary files
Binary files are very similar to arrays of structures, except the structures are in a disk-file rather than an array in memory. Binary files have two features that distinguish them from text files: More »
Posted in C Tutorials |
The function malloc is used to allocate a certain amount of memory during the execution of a program. The malloc function will request a block of memory from the heap. If the request is granted, the operating system will reserve the requested amount of memory.
When the amount of memory is not needed anymore, you must return it to the operating system by calling the function free.
Take a look at the following example: More »
Posted in C Tutorials |
The file I/O functions and types in the C language are straightforward and easy to understand. To make use of these functions and types you have to include the stdio library. (Like we already did in most of the tutorials).
The file I/O functions in the stdio library are: More »
Posted in C Tutorials |
In the C language structures are used to group together different types of variables under the same name. For example you could create a structure “telephone”: which is made up of a string (that is used to hold the name of the person) and an integer (that is used to hold the telephone number).
Take a look at the example: More »
Posted in C Tutorials |
In this C programming language tutorial we take another look at the printf function. We will look at how to use format specifiers to print formatted output onto the screen. The topics covered are; a little printf background, format specifiers and conversions, formatting of different types and format conversions of strings. More »
Posted in C Tutorials |
Important: Before you start this tutorial, did you follow the pointers and more on pointers tutorials? Strings and pointers are intertwined to a large extent.
A string in the C language is simply an array of characters. Strings must have a NULL or \0 character after the last character to show where the string ends. A string can be declared as a character array or with a string pointer. First we take a look at a character array example: More »
Posted in C Tutorials |