support@vlsimaster.com
Facebook
Instagram
Linkedin
Home
Learnings
Frontend
C
C++
Verilog
System Verilog
Backend
STA
Placement
Floor Planning
Scripting
Python
Perl
Account
Register
Login
Register as a Recruiter
More
Q&A
FAQ
About us
Contact us
Menu
Home
Learnings
Frontend
C
C++
Verilog
System Verilog
Backend
STA
Placement
Floor Planning
Scripting
Python
Perl
Account
Register
Login
Register as a Recruiter
More
Q&A
FAQ
About us
Contact us
Home
Learnings
Frontend
C
C++
Verilog
System Verilog
Backend
STA
Placement
Floor Planning
Scripting
Python
Perl
Account
Register
Login
Register as a Recruiter
More
Q&A
FAQ
About us
Contact us
Menu
Home
Learnings
Frontend
C
C++
Verilog
System Verilog
Backend
STA
Placement
Floor Planning
Scripting
Python
Perl
Account
Register
Login
Register as a Recruiter
More
Q&A
FAQ
About us
Contact us
Krutika Khakhkhar
Author of C Blogs| RTL Design Engineer
Multi Dimensional Arrays
Definition The multidimensional array will have multiple indexes, like a 2-Dimensional array will have 2 indexes and a 3-Dimensional array will have 3 indexes. A 2-D array is used when we want to take data in the form of rows and columns. In the 2-D array, the 1st index shows the number of rows and...
Array of String
Definition An array of characters is called string. Ex. One wants to store the name “RAMAN”, then he wants 5 char variables. “R” will be stored in 1st char variable, “A” in 2nd char variable and so on. So to store the whole name “RAMAN” in one variable, we can use char array up to...
Passing Array to Functions
A name of an array gives the address of the 0th element of that array, passing the array name is the same as passing the address to the function. It means if there is an array of 3 elements (ex. arr[3]), so to pass the address of array as argument of a function, we can...
String Handling
There are many library function for string handling. To use that we have to include string library , which we can do by writing #include<string.h>. One by one we are going to discuss library function and other method to perform same task without using library function. strlen : string length This function is used to...
Storage Class
Storage class is an addition to data type of a variable. It is optional to define. But to give an extra attribute to variable, it is used. As per its different types, it is used for some specific application of a variable. <storage class keyword> <data type> <variable name>; Types of storage class 1.Automatic 2.Register...
Register
We can understand all storage classes by differentiating all of those according to their default value, keyword, storage, scope, life. Which are listed in the table below. Storage Class Keyword Default Value Storage Scope Life Automatic auto Garbage RAM Limited to block in which it is declared Till execution of block in which it is...
Structure in C
As the array is used to make variables of the same data type and can be accessed by the same name but different index. The structure is used to make variables which have different variables of different data types (which are called structure members). Let us understand by an example. Ex1 is showing an array...
Usage of Struct
To declare a structure first we have to write the keyword “struct”. Then we have to write a user-defined name of the structure. After that, members of the structure are declared in curly braces. The end of the structure is shown by the semicolon “;”. The members are nothing but just declaring simple variables with...
Nested Struct
Structure within a structure is called nested structure. There are two methods for declaring structure within a structure. Those are listed below. Normally the main structure is called the outer structure and the nested structure is called the inner structure. Method 1 Declaring inner structure outside outer structure and declaring a variable of inner structure...
Array of Struct
If we want many variables of the same structure then we can make an array of structure variables. Because it is time consuming to make many variables of the same structure. Let us understand this by an example. In the below example, structure str has 3 variables: stu1, stu2. stu3, struct str{ int roll_no; float...
Unions
Whatever we studied about the structure and whatever is explained after this topic about structure is the same for union. We can use union, wherever we are using structure but there are some differences between union and structure and those are explained below. Below differences we have to keep in mind while making a program...
Passing Struct through functions
“Passing structure through function” statement has 2 meanings: Passing structure variable through function, passing structure member through function. We are going to understand both one by one. Passing structure variable through function In this, we pass the variable of structure as an argument of a function. Syntax of the same is listed below for function...
Return Structure through functions
“Returning structure through function” statement has 2 meanings: Returning structure variable through function, Returning structure member through function. We are going to understand both one by one. Returning structure variable through function Syntax of returning structure variable through function is as listed below for function declaration, call, and definition. Function declaration struct <structure name> <function...
Allocation of Memory
Structure storage in memory The members of a structure are stored consecutively in the memory. The size of members may differ from one machine to machine. But the important point to note about member storages is, they are stored consecutively in memory. Example program to understand structure member storage In the below example, there is...
Struct Copy & Comparison
Copy structure means copying all variables of a structure to another structure. Structure comparison means comparing all variables of a structure to another structure. Structure Copy We can copy the structure variable directly using ‘=’ sign, only if both source and destination variables are of the same structure. Means both structure variables must be variables...
Bit fields in Struct
In structure, there are many variables. Some of them are not even used. And some of them are used partially. This means if there is a variable of int data type then it occupies 2 bytes in memory. But suppose if the value which we are storing in it is of only 1 byte so...
Typedef for Portability
Typedef is used to change the name of any standard library data type. We are using int data type. If we want to change the name of int to any other name then we use typedef. In this, wherever we want to write keyword “int” data type then instead of keyword “int” we use the...
Logical Operator
Till now we were using bytes of any data but C provides the facility to do the operation with an individual bit of a byte. This we can do using the bitwise operator. There are 6 bitwise operators and those are listed below. These operators can work with int, char data types. Operator symbol Operator...
Compliment Operator
This is a unary operator. This means it needs one variable to do the operation. This operator first converts variables in binary then does complement operation and at the end, it converts the result to its previous data type. Let us see what happens when we do bitwise complement operation with any two bits. Syntax...
Shifting Operator
Left and Right operators are used to shift bits of a variable. First it converts that variable into its binary form and then shifts it to right or left. Using both operators, we can do multiplication and division of any variable with any number which is a power of 2. All these things we are...
Masking, Setting, Clearing and Testing of Bits
In the process of masking, we mask or filter bits of a variable. The variable is called the original value and the trail of bits that we are masking to the original value is called a mask. In this process, some bits of variables change and other bits remain as they are. We can do...
Introduction to Pointers
The C language is a very powerful language and its power is because of the pointer. With the right use of a pointer, we can make compact and very effective code using a pointer. The pointer is used for returning more than 1 value from any function, for DMA (Dynamic memory allocation), to access members...
Pointer Address and Value
For pointers in C language, & and * operators are very important. To use a pointer, the understanding of both operators is a must. The meaning of both is as explained below. Meaning of & operator ‘&’ operator is called address operator. We can spell ‘&’ as “address of” whenever we are using it. This...
Declaration and Assignment of Pointer
Now as we know meaning of & and * operators. We are going to declare and assign a pointer variable. Both are explained below. But the first most important thing about pointers is, “Data type of pointer and data type of variable (whose pointer we are creating) must be the same”. This means we want...
Pointer Arithmetic
Pointer arithmetic means adding or subtracting values to the pointer variable. This is not the same as those simple arithmetic operations in normal variables. So how pointer arithmetic is different from simple arithmetic is explained below. Adding integer to pointer Suppose ‘p’ is a pointer to the ‘a’ variable. If we are adding n to...
Multiple Indirections
Multiple indirections are called pointer of pointer or chain of pointer. So how to make a chain of pointer and how to use it is explained below. Here we will learn up to two levels of a pointer. For more levels, we need more indirection operators to use. Syntax of declaring pointer of pointer Syntax...
Generic and Null Pointer
In this session, we are going to understand the meaning & use of a generic and NULL pointer. Generic pointer (void pointer) The generic pointer is also called void pointer also. With pointer declaration, we have to specify its data type also. That data type is the same as the data type of that variable,...
Pointer as return type of function
When any function is returning an address then the return data type of that function must be a pointer. Because returning value is an address, to store an address we need a pointer. In short, to hold an address we need a pointer so the function which returns the address needs a pointer variable to...
Pointer to Arrays
Pointer to array and array to a pointer, both are totally different things. In this section, we are going to understand the pointer to an array. Actually, the name of the character array (string), itself is a pointer. Below lines will print the address of str string. Ex1. char str[10]=”abcdef”; printf(“%u”,str); //%u...
Pointer to Structure and Union
In this topic, we are going to learn the syntax and the use of pointers to structure and union. Pointer to structure and union is the same as a pointer to a simple variable. Working and purpose of structure and union will remain the same. When we want to store the address of a specific...
malloc(), calloc(), realloc(), free()
Whichever memory that we have used till now was static memory. We can not change that memory while executing that program. But in some applications, we do not know how much memory we need. Let’s take an example to understand this. An array arr stores the roll number of students in class. Ex. int arr[50]; ...
Introduction to File Data Type
Whatever programs we have done till now, those outputs were shown on screen. But that data was not stored in any secondary memory. This means those data were stored in primary memory, when we close the program then that data is permanently lost. We need some secondary memory storage to store data which is available...
Usage of File
In this blog, we are going to learn how to make a file pointer and how to open and close a file using a file pointer. File pointer In each program where we are using file handling, we have to make a file pointer at the start of the program (before using any file operation)....
Character Input and Output
Character I/O includes getc(), putc(), fgetc(), fputc() functions. Those functions we are going to discuss in this blog. file pointer pointing any location Basically, the file pointer is a pointer to a structure and when it points to any location. It contains some information like file is being read/append/written, end of file reached or not,...
Integer Input and Output
Integer I/O includes getw(), putw() functions. Those functions we are going to discuss in this blog. putw() This function is used to write any integer into a file. After writing any integer (or reading), the pointer will point to the next location. The syntax is written below. putw(<integer that we want to pass>,<file pointer name>);...
Formatted Input and Output
Formatted I/O includes fprintf(), fscanf() functions. Those functions we are going to discuss in this blog. fprintf() This function is used to write multiple variables of multiple data types into a file. Suppose if we want to write an integer array and one float variable into a file then we can use this function. fprintf(<file...
Random Access to File
Functions like fseek(), ftell() and rewind() are included in the “Random Access to file” topic. Those functions we are going to discuss in this blog. fprintf() This function is used to write multiple variables of multiple data types into a file. Suppose if we want to write an integer array and one float variable into...
Usage of Arrays
An array is said to be a collection of some data items, those all are of the same type and all can be accessed using one common name. We can say that an array is a group of multiple variables having the same data type, those differ from their index of the array. If one...
String Input and Output
String I/O includes fgets(), fputs()functions. Those functions we are going to discuss in this blog. fputs() This function is used to write any string into a file. After writing any string (or reading), the pointer will point to the next location. Below is the syntax for fputs function. fputs(“<string that we want to write>”,<file pointer...