The assert.h header file of the C Standard Library provides a macro called assert which can be used to verify assumptions made by the program and print a diagnostic message if this assumption is false.
Labels
.
Search Your Article
Total Pageviews
Thursday, January 26, 2017
C Library -
The ctype.h header file of the C Standard Library declares several functions that are useful for testing and mapping characters.
All the functions accepts int as a parameter, whose value must be EOF or representable as an unsigned char.
All the functions return non-zero (true) if the argument c satisfies the condition described, and zero(false) if not.
All the functions accepts int as a parameter, whose value must be EOF or representable as an unsigned char.
All the functions return non-zero (true) if the argument c satisfies the condition described, and zero(false) if not.
C Library -
The errno.h header file of the C Standard Library defines the integer variable errno,
which is set by system calls and some library functions in the event of
an error to indicate what went wrong. This macro expands to a
modifiable lvalue of type int, therefore it can be both read and
modified by a program.
C Library -
The float.h header file of the C Standard Library contains a
set of various platform-dependent constants related to floating point
values. These constants are proposed by ANSI C. They allow making more
portable programs. Before checking all the constants, it is good to
understand that floating-point number is composed of following four
elements −
C Library -
The limits.h header determines various properties of the
various variable types. The macros defined in this header, limits the
values of various variable types like char, int and long.
These limits specify that a variable cannot store any value beyond these limits, for example an unsigned character can store up to a maximum value of 255.
These limits specify that a variable cannot store any value beyond these limits, for example an unsigned character can store up to a maximum value of 255.
C Library -
The locale.h header defines the location specific settings,
such as date formats and currency symbols. You will find several macros
defined along with an important structure struct lconv and two important functions listed below.
C Library -
The math.h header defines various mathematical functions and one macro. All the functions available in this library take double as an argument and return double as the result.
C Library -
The setjmp.h header defines the macro setjmp(), one function longjmp(), and one variable type jmp_buf, for bypassing the normal function call and return discipline.
C Library -
The signal.h header defines a variable type sig_atomic_t, two function calls, and several macros to handle different signals reported during a program's execution.
C Library -
The stdarg.h header defines a variable type va_list and
three macros which can be used to get the arguments in a function when
the number of arguments are not known i.e. variable number of arguments.
A function of variable arguments is defined with the ellipsis (,...) at the end of the parameter list.
A function of variable arguments is defined with the ellipsis (,...) at the end of the parameter list.
C Library -
The stddef.h header defines various variable types and macros. Many of these definitions also appear in other headers.
C Library -
The stdio.h header defines three variable types, several macros, and various functions for performing input and output.
C Library -
The stdlib.h header defines four variable types, several macros, and various functions for performing general functions.
C Library -
The string.h header defines one variable type, one macro, and various functions for manipulating arrays of characters.
C Library -
The time.h header defines four variable types, two macro and various functions for manipulating date and time.
Discuss C Standard Library
C is a general-purpose, procedural, imperative computer programming
language developed in 1972 by Dennis M. Ritchie at the Bell Telephone
Laboratories to develop the Unix operating system.
C Tutorial
C is a general-purpose, procedural, imperative computer programming
language developed in 1972 by Dennis M. Ritchie at the Bell Telephone
Laboratories to develop the UNIX operating system. C is the most widely
used computer language. It keeps fluctuating at number one scale of
popularity along with Java programming language, which is also equally
popular and most widely used among modern software programmers.
Audience
This tutorial is designed for software programmers with a need to understand the C programming language starting from scratch. This tutorial will give you enough understanding on C programming language from where you can take yourself to higher level of expertise.C - Useful Resources
The following resources contain additional information on C. Please use them to get more in-depth knowledge on this topic.
AWK - Overview
AWK is an interpreted programming language. It is very powerful and
specially designed for text processing. Its name is derived from the
family names of its authors − Alfred Aho, Peter Weinberger, and Brian Kernighan.
AWK - Environment
This chapter describes how to set up the AWK environment on your GNU/Linux system.
Installation Using Package Manager
AWK - Workflow
To become an expert AWK programmer, you need to know its internals.
AWK follows a simple workflow − Read, Execute, and Repeat. The following
diagram depicts the workflow of AWK −
AWK - Basic Syntax
AWK is simple to use. We can provide AWK commands either directly
from the command line or in the form of a text file containing AWK
commands.
AWK - Basic Examples
This chapter describes several useful AWK commands and their appropriate examples. Consider a text file marks.txt to be processed with the following content −
1) Amit Physics 80 2) Rahul Maths 90 3) Shyam Biology 87 4) Kedar English 85 5) Hari History 89
AWK - Built-in Variables
AWK provides several built-in variables. They play an important role
while writing AWK scripts. This chapter demonstrates the usage of
built-in variables.
Standard AWK variables
The standard AWK variables are discussed below.AWK - Operators
Like other programming languages, AWK also provides a large set of
operators. This chapter explains AWK operators with suitable examples.
AWK - Regular Expressions
AWK is very powerful and efficient in handling regular expressions. A
number of complex tasks can be solved with simple regular expressions.
Any command-line expert knows the power of regular expressions.
This chapter covers standard regular expressions with suitable examples.
This chapter covers standard regular expressions with suitable examples.
AWK - Arrays
AWK has associative arrays and one of the best thing about it is –
the indexes need not to be continuous set of number; you can use either
string or number as an array index. Also, there is no need to declare
the size of an array in advance – arrays can expand/shrink at runtime.
Its syntax is as follows −
Its syntax is as follows −
AWK - Control Flow
Like other programming languages, AWK provides conditional statements
to control the flow of a program. This chapter explains AWK's control
statements with suitable examples.
AWK - Loops
This chapter explains AWK's loops with suitable example. Loops are
used to execute a set of actions in a repeated manner. The loop
execution continues as long as the loop condition is true.
AWK - Built-in Functions
AWK has a number of functions built into it that are always available
to the programmer. This chapter describes Arithmetic, String, Time, Bit
manipulation, and other miscellaneous functions with suitable examples.
AWK - User Defined Functions
Functions are basic building blocks of a program. AWK allows us to
define our own functions. A large program can be divided into functions
and each function can be written/tested independently. It provides
re-usability of code.
Given below is the general format of a user-defined function −
Given below is the general format of a user-defined function −
AWK - Output Redirection
So far, we displayed data on standard output stream. We can also redirect data to a file. A redirection appears after the print or printf
statement. Redirections in AWK are written just like redirection in
shell commands, except that they are written inside the AWK program.
This chapter explains redirection with suitable examples.
AWK - Pretty Printing
So far we have used AWK's print and printf functions to
display data on standard output. But printf is much more powerful than
what we have seen before. This function is borrowed from the C language
and is very helpful while producing formatted output. Below is the
syntax of the printf statement −
AWK - Quick Guide
AWK - Overview
AWK is an interpreted programming language. It is very powerful and specially designed for text processing. Its name is derived from the family names of its authors − Alfred Aho, Peter Weinberger, and Brian Kernighan.AWK - Useful Resources
The following resources contain additional information on AWK. Please use them to get more in-depth knowledge on this.
Discuss AWK
This tutorial takes you through AWK, one of the most prominent
text-processing utility on GNU/Linux. It is very powerful and uses
simple programming language. It can solve complex text processing tasks
with a few lines of code.
Assembly - Introduction
What is Assembly Language?
Each personal computer has a microprocessor that manages the computer's arithmetical, logical, and control activities.Each family of processors has its own set of instructions for handling various operations such as getting input from keyboard, displaying information on screen and performing various other jobs.
Assembly - Environment Setup
Try it Option Online
We already have set up NASM assembler to experiment with Assembly programming online, so that you can execute all the available examples online at the same time when you are doing your theory work.
Assembly - Basic Syntax
An assembly program can be divided into three sections −
- The data section,
- The bss section, and
- The text section.
Assembly - Memory Segments
We have already discussed the three sections of an assembly program. These sections represent various memory segments as well.
Interestingly, if you replace the section keyword with segment, you will get the same result. Try the following code −
Interestingly, if you replace the section keyword with segment, you will get the same result. Try the following code −
Assembly - Registers
Processor operations mostly involve processing data. This data can be
stored in memory and accessed from thereon. However, reading data from
and storing data into memory slows down the processor, as it involves
complicated processes of sending the data request across the control bus
and into the memory storage unit and getting the data through the same
channel.
Assembly - System Calls
System calls are APIs for the interface between the user space and
the kernel space. We have already used the system calls. sys_write and
sys_exit, for writing into the screen and exiting from the program,
respectively.
Assembly - Addressing Modes
Most assembly language instructions require operands to be processed.
An operand address provides the location, where the data to be
processed is stored. Some instructions do not require an operand,
whereas some other instructions may require one, two, or three operands.
Assembly - Variables
NASM provides various define directives for reserving storage
space for variables. The define assembler directive is used for
allocation of storage space. It can be used to reserve as well as
initialize one or more bytes.
Assembly - Constants
There are several directives provided by NASM that define constants.
We have already used the EQU directive in previous chapters. We will
particularly discuss three directives −
Assembly - Arithmetic Instructions
The INC Instruction
The INC instruction is used for incrementing an operand by one. It works on a single operand that can be either in a register or in memory.Assembly - Logical Instructions
The processor instruction set provides the instructions AND, OR, XOR,
TEST, and NOT Boolean logic, which tests, sets, and clears the bits
according to the need of the program.
The format for these instructions −
The format for these instructions −
Assembly - Conditions
Conditional execution in assembly language is accomplished by several
looping and branching instructions. These instructions can change the
flow of control in a program. Conditional execution is observed in two
scenarios −
Assembly - Loops
The JMP instruction can be used for implementing loops. For example,
the following code snippet can be used for executing the loop-body 10
times.
MOV CL, 10 L1: <LOOP-BODY>
Assembly - Numbers
Numerical data is generally represented in binary system. Arithmetic
instructions operate on binary data. When numbers are displayed on
screen or entered from keyboard, they are in ASCII form.
Assembly - Strings
We have already used variable length strings in our previous
examples. The variable length strings can have as many characters as
required. Generally, we specify the length of the string by either of
the two ways −
- Explicitly storing string length
- Using a sentinel character
Assembly - Arrays
We have already discussed that the data definition directives to the
assembler are used for allocating storage for variables. The variable
could also be initialized with some specific value. The initialized
value could be specified in hexadecimal, decimal or binary form.
Assembly - Procedures
Procedures or subroutines are very important in assembly language, as
the assembly language programs tend to be large in size. Procedures are
identified by a name. Following this name, the body of the procedure is
described which performs a well-defined job. End of the procedure is
indicated by a return statement.
Assembly - Recursion
A recursive procedure is one that calls itself. There are two kind of
recursion: direct and indirect. In direct recursion, the procedure
calls itself and in indirect recursion, the first procedure calls a
second procedure, which in turn calls the first procedure.
Assembly - Macros
Writing a macro is another way of ensuring modular programming in assembly language.
- A macro is a sequence of instructions, assigned by a name and could be used anywhere in the program.
- In NASM, macros are defined with %macro and %endmacro directives.
- The macro begins with the %macro directive and ends with the %endmacro directive.
Assembly - File Management
The system considers any input or output data as stream of bytes. There are three standard file streams −
- Standard input (stdin),
- Standard output (stdout), and
- Standard error (stderr).
Assembly - Memory Management
The sys_brk() system call is provided by the kernel, to
allocate memory without the need of moving it later. This call allocates
memory right behind the application image in the memory. This system
function allows you to set the highest available address in the data
section.
Assembly - Quick Guide
Assembly - Introduction
What is Assembly Language?
Each personal computer has a microprocessor that manages the computer's arithmetical, logical, and control activities.Assembly - Useful Resources
The following resources contain additional information on Assembly
Programming. Please use them to get more in-depth knowledge on this
topic.
Discuss Assembly Programming
Assembly language is a low-level programming language for a computer or
other programmable device specific to a particular computer architecture
in contrast to most high-level programming languages, which are
generally portable across multiple systems. Assembly language is
converted into executable machine code by a utility program referred to
as an assembler like NASM, MASM, etc.
Arduino - Overview
Arduino is a prototype platform (open-source) based on an easy-to-use
hardware and software. It consists of a circuit board, which can be
programed (referred to as a microcontroller) and a ready-made software
called Arduino IDE (Integrated Development Environment), which is used
to write and upload the computer code to the physical board.
The key features are −
The key features are −
Arduino - Board Description
In this chapter, we will learn about the different components on the
Arduino board. We will study the Arduino UNO board because it is the
most popular board in the Arduino board family. In addition, it is the
best board to get started with electronics and coding. Some boards look a
bit different from the one given below, but most Arduinos have majority
of these components in common.
Arduino - Installation
After learning about the main parts of the Arduino UNO board, we are
ready to learn how to set up the Arduino IDE. Once we learn this, we
will be ready to upload our program on the Arduino board.
In this section, we will learn in easy steps, how to set up the Arduino IDE on our computer and prepare the board to receive the program via USB cable.
In this section, we will learn in easy steps, how to set up the Arduino IDE on our computer and prepare the board to receive the program via USB cable.
Arduino - Program Structure
In this chapter, we will study in depth, the Arduino program
structure and we will learn more new terminologies used in the Arduino
world. The Arduino software is open-source. The source code for the Java
environment is released under the GPL and the C/C++ microcontroller
libraries are under the LGPL.
Sketch − The first new terminology is the Arduino program called “sketch”.
Sketch − The first new terminology is the Arduino program called “sketch”.
Arduino - Data Types
Data types in C refers to an extensive system used for declaring
variables or functions of different types. The type of a variable
determines how much space it occupies in the storage and how the bit
pattern stored is interpreted.
Arduino - Variables & Constants
Before we start explaining the variable types, a very important
subject we need to make sure, you fully understand is called the variable scope.
Arduino - Operators
An operator is a symbol that tells the compiler to perform specific
mathematical or logical functions. C language is rich in built-in
operators and provides the following types of operators −
Arduino - Control Statements
Decision making structures require that the programmer specify one or
more conditions to be evaluated or tested by the program. It should be
along with a statement or statements to be executed if the condition is
determined to be true, and optionally, other statements to be executed
if the condition is determined to be false.
Arduino - Loops
Programming languages provide various control structures that allow for more complicated execution paths.
A loop statement allows us to execute a statement or group of statements multiple times and following is the general form of a loop statement in most of the programming languages −
A loop statement allows us to execute a statement or group of statements multiple times and following is the general form of a loop statement in most of the programming languages −
Arduino - Functions
Functions allow structuring the programs in segments of code to
perform individual tasks. The typical case for creating a function is
when one needs to perform the same action multiple times in a program.
Standardizing code fragments into functions has several advantages −
Standardizing code fragments into functions has several advantages −
Arduino - Strings
Strings are used to store text. They can be used to display text on
an LCD or in the Arduino IDE Serial Monitor window. Strings are also
useful for storing the user input. For example, the characters that a
user types on a keypad connected to the Arduino.
There are two types of strings in Arduino programming −
There are two types of strings in Arduino programming −
Arduino - String Object
The second type of string used in Arduino programming is the String Object.
What is an Object?
An object is a construct that contains both data and functions. A String object can be created just like a variable and assigned a value or string. The String object contains functions (which are calledArduino - Arrays
An array is a consecutive group of memory locations that are of the
same type. To refer to a particular location or element in the array, we
specify the name of the array and the position number of the particular
element in the array.
Arduino - I/O Functions
The pins on the Arduino board can be configured as either inputs or
outputs. We will explain the functioning of the pins in those modes. It
is important to note that a majority of Arduino analog pins, may be
configured, and used, in exactly the same manner as digital pins.
Arduino - Advanced I/O Function
In this chapter, we will learn some advanced Input and Output Functions.
analogReference() Function
Configures the reference voltage used for analog input (i.e. the value used as the top of the input range). The options are −Arduino - Character Functions
All data is entered into computers as characters, which includes
letters, digits and various special symbols. In this section, we discuss
the capabilities of C++ for examining and manipulating individual
characters.
Arduino - Math Library
The Arduino Math library (math.h) includes a number of useful mathematical functions for manipulating floating-point numbers.
Arduino - Trigonometric Functions
You need to use Trigonometry practically like calculating the
distance for moving object or angular speed. Arduino provides
traditional trigonometric functions (sin, cos, tan, asin, acos, atan)
that can be summarized by writing their prototypes. Math.h contains the
trigonometry function's prototype.
Arduino - Due & Zero
The Arduino Due is a microcontroller board based on the Atmel SAM3X8E ARM Cortex-M3 CPU. It is the first Arduino board based on a 32-bit ARM core microcontroller.
Important features −
Important features −
Arduino - Pulse Width Modulation
Pulse Width Modulation or PWM is a common technique used to vary the width of the pulses in a pulse-train. PWM has many applications such as controlling servos and speed controllers, limiting the effective power of motors and LEDs.
Arduino - Random Numbers
To generate random numbers, you can use Arduino random number functions. We have two functions −
- randomSeed(seed)
- random()
randomSeed (seed)
Arduino - Interrupts
Interrupts stop the current work of Arduino such that some other work can be done.
Suppose you are sitting at home, chatting with someone. Suddenly the telephone rings. You stop chatting, and pick up the telephone to speak to the caller.
Suppose you are sitting at home, chatting with someone. Suddenly the telephone rings. You stop chatting, and pick up the telephone to speak to the caller.
Arduino - Communication
Hundreds of communication protocols have been defined to achieve this data exchange. Each protocol can be categorized into one of the two categories: parallel or serial.
Arduino - Inter Integrated Circuit
Inter-integrated circuit (I2C) is a system for serial data exchange between the microcontrollers and specialized integrated circuits of a new generation. It is used when the distance between them is short (receiver and transmitter are usually on the same printed board). Connection is established via two conductors. One is used for data transfer and the other is used for synchronization (clock signal).
Arduino - Serial Peripheral Interface
A Serial Peripheral Interface (SPI) bus is a system for serial
communication, which uses up to four conductors, commonly three. One
conductor is used for data receiving, one for data sending, one for
synchronization and one alternatively for selecting a device to
communicate with.
Subscribe to:
Posts (Atom)