Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • C
  • C Basics
  • C Data Types
  • C Operators
  • C Input and Output
  • C Control Flow
  • C Functions
  • C Arrays
  • C Strings
  • C Pointers
  • C Preprocessors
  • C File Handling
  • C Programs
  • C Cheatsheet
  • C Interview Questions
  • C MCQ
  • C++
Open In App
Next Article:
How can I return multiple values from a function?
Next article icon

Function Prototype in C

Last Updated : 02 Jan, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

In C, a function prototype is a statement that tells the compiler about the function’s name, its return type, numbers, and data types of its parameters. Using this information, the compiler cross-checks function parameters and their data type with function definition and function call.

For example, let’s create a function prototype for a function that adds two numbers which it takes as arguments and returns their sum:

C
// Not a prototype as it does not contain the number // and type of parameters. It is only declaration int sum();  // Valid prototype as it contains function name, // return type, number and type of parameters int sum(int, int);  // Also a valid prototype int sum(int a, int b);  // Function definition inherently contains function // prototype int sum(int a, int b) {   	return a + b; } 

General Syntax

return_type name(type1, type2 ….);

where,

  • return_type : Type of value the function returns.
  • name: Name of the function
  • type1, type2 ….: Type of the parameters. Specifying their names is optional.

Function prototype can be used in place of function declaration in cases where the function reference or call is present before the function definition but optional if the function definition is present before the function call in the program.

What Happens If the Function Prototype Is Missing?

When the function prototype is missing in C, the compiler generally gives two warnings:

  1. Implicit Declaration Warning.
  2. Incorrect return type warning (in case where the function should return non-integer value)

The first warning is understandable as the compiler cannot find the function with the given name. The other warning is due to the fact that the compiler assumes the return type to be int by default in case of missing return type(or whole prototype).

The below program demonstrate this:

C
#include <errno.h> #include <stdio.h>  int main(int argc, char* argv[]) { 	FILE* fp;  	fp = fopen(argv[1], "r"); 	if (fp == NULL) {              	// Calling strerror() which is defined inside       	// string.h header file 		fprintf(stderr, "%s\n", strerror(errno)); 		return errno; 	}  	printf("file exist\n");  	fclose(fp);  	return 0; } 


Output

solution.c: In function ‘main’: solution.c:14:41: warning: implicit declaration of function ‘strerror’; did you mean ‘perror’? [-Wimplicit-function-declaration]    14 |                 fprintf(stderr, "%s\n", strerror(errno));       |                                         ^~~~~~~~       |                                         perror solution.c:14:35: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat=]    14 |                 fprintf(stderr, "%s\n", strerror(errno));       |                                  ~^     ~~~~~~~~~~~~~~~       |                                   |     |       |                                   |     int       |                                   char *       |                                  %d Segmentation fault (core dumped)

Explanation

The above program checks the existence of a file, provided from the command line, if a given file exists, then the program prints “file exists”, otherwise it prints an appropriate error message.

Why did this program crash, instead it should show an appropriate error message. This program will work fine on x86 architecture but will crash on x86_64 architecture. Let us see what was wrong with the code. Carefully go through the program, deliberately I haven’t included the prototype of the “strerror()” function. This function returns a “pointer to the character”, which will print an error message which depends on the errno passed to this function.

Note that x86 architecture is an ILP-32 model, which means integers, pointers, and long are 32-bit wide, that’s why the program will work correctly on this architecture. But x86_64 is the LP-64 model, which means long and pointers are 64-bit wide. In C language, when we don’t provide a prototype of a function, the compiler assumes that the function returns an integer. In our example, we haven’t included the “string.h” header file (strerror’s prototype is declared in this file), that’s why the compiler assumed that the function returns an integer. But its return type is a pointer to a character.

In x86_64, pointers are 64-bit wide and integers are 32-bit wide, that’s why while returning from a function, the returned address gets truncated (i.e. 32-bit wide address, which is the size of integer on x86_64) which is invalid and when we try to dereference this address, the result is a segmentation fault.

Now include the “string.h” header file and check the output, the program will work correctly and gives the following output.

Benifits of Function Prototypes

Following are the major benefits of including function prototypes in your program:

  • Function Declaration Before Definition: It allows a function to be called before its definition. In large programs, it is common to place function prototypes at the beginning of the code or in header files, enabling function calls to occur before the function’s actual implementation.
  • Type Checking: A function prototype allows the compiler to check that the correct number and type of arguments are passed to the function. If the function is called with the wrong type or number of parameters, the compiler can catch the error.
  • Code Clarity: By declaring prototypes, you inform the programmer about the function’s purpose and expected parameters, which helps in understanding the code structure.

Function Declaration vs Prototype

The terms function declaration and function prototypes are often used interchangeably but they are different in the purpose and their meaning. Following are the major differences between the function declaration and function prototype in C:

Function Declaration

Function Prototype

Function Declaration is used to tell the existence of a function.The function prototype tells the compiler about the existence and signature of the function.
A function declaration is valid even with only function name and return type.                                                                                                      A function prototype is a function delcaration that provides the function’s name, return type, and parameter list without including the function body.
Typically used in header files to declare functions.Used to declare functions before their actual definitions.

Syntax:

return_type function_name();

Syntax:

return_type function_name(parameter_list);



Next Article
How can I return multiple values from a function?
author
kartik
Improve
Article Tags :
  • C Language
  • C-Functions

Similar Reads

  • C Programming Language Tutorial
    C is a general-purpose, procedural, and middle-level programming language developed by Dennis M. Ritchie at Bell Laboratories in 1972. It is also known as the "mother of all programming languages" as it influenced many modern programming languages like C++, Java, Python, and Go. Why learn C?The C la
    5 min read
  • C Basics

    • C Language Introduction
      C is a general-purpose procedural programming language initially developed by Dennis Ritchie in 1972 at Bell Laboratories of AT&T Labs. It was mainly created as a system programming language to write the UNIX operating system. Why Learn C?C is considered mother of all programming languages as ma
      6 min read

    • Features of C Programming Language
      C is a procedural programming language. It was initially developed by Dennis Ritchie in the year 1972. It was mainly developed as a system programming language to write an operating system. The main features of C language include low-level access to memory, a simple set of keywords, and a clean styl
      3 min read

    • C Programming Language Standard
      Introduction:The C programming language has several standard versions, with the most commonly used ones being C89/C90, C99, C11, and C18. C89/C90 (ANSI C or ISO C) was the first standardized version of the language, released in 1989 and 1990, respectively. This standard introduced many of the featur
      6 min read

    • C Hello World Program
      The “Hello World” program is the first step towards learning any programming language. It is also one of the simplest programs that is used to introduce aspiring programmers to the programming language. It typically outputs the text "Hello, World!" to the console screen. C Program to Print "Hello Wo
      1 min read

    • Compiling a C Program: Behind the Scenes
      The compilation is the process of converting the source code of the C language into machine code. As C is a mid-level language, it needs a compiler to convert it into an executable code so that the program can be run on our machine. The C program goes through the following phases during compilation:
      4 min read

    • C Comments
      The comments in C are human-readable explanations or notes in the source code of a C program. A comment makes the program easier to read and understand. These are the statements that are not executed by the compiler or an interpreter. Example: [GFGTABS] C #include <stdio.h> int main() { // Thi
      3 min read

    • Tokens in C
      In C programming, tokens are the smallest units in a program that have meaningful representations. Tokens are the building blocks of a C program, and they are recognized by the C compiler to form valid expressions and statements. Tokens can be classified into various categories, each with specific r
      4 min read

    • Keywords in C
      In C Programming language, there are many rules so to avoid different types of errors. One of such rule is not able to declare variable names with auto, long, etc. This is all because these are keywords. Let us check all keywords in C language. What are Keywords?Keywords are predefined or reserved w
      11 min read

    C Variables and Constants

    • C Variables
      A variable in C is a named piece of memory which is used to store data and access it whenever required. It allows us to use the memory without having to memorize the exact memory address. Syntax for Creating VariablesTo create a variable in C, we have to specify a name and the type of data it is goi
      5 min read

    • Constants in C
      In C programming, constants are read-only values that cannot be modified during the execution of a program. These constants can be of various types, such as integer, floating-point, string, or character constants. They are initialized with the declaration and remain same till the end of the program.
      3 min read

    • Const Qualifier in C
      The qualifier const can be applied to the declaration of any variable to specify that its value will not be changed (which depends upon where const variables are stored, we may change the value of the const variable by using a pointer). The result is implementation-defined if an attempt is made to c
      6 min read

    • Different ways to declare variable as constant in C
      There are many different ways to make the variable as constant in C. Some of the popular ones are: Using const KeywordUsing MacrosUsing enum Keyword1. Using const KeywordThe const keyword specifies that a variable or object value is constant and can't be modified at the compilation time. Syntaxconst
      2 min read

    • Scope rules in C
      The scope of a variable in C is the block or the region in the program where a variable is declared, defined, and used. Outside this region, we cannot access the variable, and it is treated as an undeclared identifier. The scope is the area under which a variable is visible.The scope of an identifie
      6 min read

    • Internal Linkage and External Linkage in C
      In C, linkage is a concept that describes how names/identifiers can or cannot refer to the same entity throughout the whole program or a single translation unit. The above sounds similar to scope, but it is not so. To understand what the above means, let us dig deeper into the compilation process. B
      5 min read

    • Global Variables in C
      Prerequisite: Variables in C In a programming language, each variable has a particular scope attached to them. The scope is either local or global. This article will go through global variables, their advantages, and their properties. The Declaration of a global variable is very similar to that of a
      3 min read

    C Data Types

    • Data Types in C
      Each variable in C has an associated data type. It specifies the type of data that the variable can store like integer, character, floating, double, etc. Example: [GFGTABS] C++ int number; [/GFGTABS]The above statement declares a variable with name number that can store integer values. C is a static
      6 min read

    • Literals in C
      In C, Literals are the constant values that are assigned to the variables. Literals represent fixed values that cannot be modified. Literals contain memory but they do not have references as variables. Generally, both terms, constants, and literals are used interchangeably. For example, “const int =
      4 min read

    • Escape Sequence in C
      The escape sequence in C is the characters or the sequence of characters that can be used inside the string literal. The purpose of the escape sequence is to represent the characters that cannot be used normally using the keyboard. Some escape sequence characters are the part of ASCII charset but so
      5 min read

    • bool in C
      The bool in C is a fundamental data type in most that can hold one of two values: true or false. It is used to represent logical values and is commonly used in programming to control the flow of execution in decision-making statements such as if-else statements, while loops, and for loops. In this a
      6 min read

    • Integer Promotions in C
      Some data types like char , short int take less number of bytes than int, these data types are automatically promoted to int or unsigned int when an operation is performed on them. This is called integer promotion. For example no arithmetic calculation happens on smaller types like char, short and e
      2 min read

    • Character Arithmetic in C
      As already known character range is between -128 to 127 or 0 to 255. This point has to be kept in mind while doing character arithmetic. What is Character Arithmetic?Character arithmetic is used to implement arithmetic operations like addition, subtraction, multiplication, and division on characters
      2 min read

    • Type Conversion in C
      In C, type conversion refers to the process of converting one data type to another. It can be done automatically by the compiler or manually by the programmer. The type conversion is only performed to those data types where conversion is possible. Let's take a look at an example: [GFGTABS] C #includ
      4 min read

    C Input/Output

    • Basic Input and Output in C
      In C programming, input and output operations refer to reading data from external sources and writing data to external destinations outside the program. C provides a standard set of functions to handle input from the user and output to the screen or to files. These functions are part of the standard
      5 min read

    • Format Specifiers in C
      The format specifier in C is used to tell the compiler about the type of data to be printed or scanned in input and output operations. They always start with a % symbol and are used in the formatted string in functions like printf(), scanf, sprintf(), etc. The C language provides a number of format
      6 min read

    • printf in C
      In C language, printf() function is used to print formatted output in many ways to the standard output stdout (which is generally the console screen). Example: [GFGTABS] C #include <stdio.h> int main() { // Using printf to print the text "Hi!" printf("Hi!"); return 0; } [/G
      6 min read

    • scanf in C
      In C, scanf() is a function is used to read data from stdin (standard input stream i.e. usually keyboard) and stores the result into the given arguments. It is defined in the <stdio.h> header file. Example: [GFGTABS] C #include <stdio.h> int main() { int n; // Reading an integer input sc
      4 min read

    • Scansets in C
      scanf family functions support scanset specifiers which are represented by %[]. Inside scanset, we can specify single character or range of characters. While processing scanset, scanf will process only those characters which are part of scanset. We can define scanset by putting characters inside squ
      2 min read

    • Formatted and Unformatted Input/Output functions in C with Examples
      This article focuses on discussing the following topics in detail- Formatted I/O Functions.Unformatted I/O Functions.Formatted I/O Functions vs Unformatted I/O Functions.Formatted I/O Functions Formatted I/O functions are used to take various inputs from the user and display multiple outputs to the
      9 min read

    C Operators

    • Operators in C
      In C language, operators are symbols that represent some kind of operations to be performed. They are the basic components of the C programming. In this article, we will learn about all the operators in C with examples. What is an Operator in C?A C operator can be defined as the symbol that helps us
      13 min read

    • Arithmetic Operators in C
      Arithmetic operators are the type of operators used to perform basic math operations like addition, subtraction, and multiplication. Let's take a look at an example: [GFGTABS] C #include <stdio.h> int main() { // Calculate the area of the triangle int sum = 10 + 20; printf("%d", sum)
      5 min read

    • Unary Operators in C
      In C programming, unary operators are operators that operate on a single operand. These operators are used to perform operations such as negation, incrementing or decrementing a variable, or checking the size of a variable. They provide a way to modify or manipulate the value of a single variable in
      6 min read

    • Relational Operators in C
      In C, relational operators are the symbols that are used for comparison between two values to understand the type of relationship a pair of numbers shares. The result that we get after the relational operation is a boolean value, that tells whether the comparison is true or false. Relational operato
      4 min read

    • Bitwise Operators in C
      In C, bitwise operators are used to perform operations directly on the binary representations of numbers. These operators work by manipulating individual bits (0s and 1s) in a number. The following 6 operators are bitwise operators (also known as bit operators as they work at the bit-level). They ar
      6 min read

    • C Logical Operators
      Logical operators in C are used to combine multiple conditions/constraints. Logical Operators returns either 0 or 1, it depends on whether the expression result is true or false. In C programming for decision-making, we use logical operators. We have 3 logical operators in the C language: Logical AN
      5 min read

    • Assignment Operators in C
      In C, assignment operators are used to assign values to variables. The left operand is the variable and the right operand is the value being assigned. The value on the right must match the data type of the variable otherwise, the compiler will raise an error. Let's take a look at an example: [GFGTAB
      5 min read

    • Increment and Decrement Operators in C
      The increment ( ++ ) and decrement ( -- ) operators in C are unary operators for incrementing and decrementing the numeric values by 1 respectively. The incrementation and decrementation are one of the most frequently used operations in programming for looping, array traversal, pointer arithmetic, a
      4 min read

    • Conditional or Ternary Operator (?:) in C
      The conditional operator in C is kind of similar to the if-else statement as it follows the same algorithm as of if-else statement but the conditional operator takes less space and helps to write the if-else statements in the shortest way possible. It is also known as the ternary operator in C as it
      3 min read

    • sizeof operator in C
      Sizeof is a much-used operator in the C. It is a compile-time unary operator which can be used to compute the size of its operand. The result of sizeof is of the unsigned integral type which is usually denoted by size_t. sizeof can be applied to any data type, including primitive types such as integ
      3 min read

    • Operator Precedence and Associativity in C
      Operator precedence and associativity are rules that decide the order in which parts of an expression are calculated. Precedence tells us which operators should be evaluated first, while associativity determines the direction (left to right or right to left) in which operators with the same preceden
      8 min read

    C Control Statements Decision-Making

    • Decision Making in C (if , if..else, Nested if, if-else-if )
      In C, programs can choose which part of the code to execute based on some condition. This ability is called decision making and the statements used for it are called conditional statements. These statements evaluate one or more conditions and make the decision whether to execute a block of code or n
      8 min read

    • C - if Statement
      The if in C is the simplest decision-making statement. It consists of the test condition and a block of code that is executed if and only if the given condition is true. Otherwise, it is skipped from execution. Let's take a look at an example: [GFGTABS] C #include <stdio.h> int main() { int n
      4 min read

    • C if else Statement
      The if else in C is an extension of the if statement which not only allows the program to execute one block of code if a condition is true, but also a different block if the condition is false. This enables making decisions with two possible outcomes. Let's take a look at an example: [GFGTABS] C #in
      3 min read

    • C if else if ladder
      In C, if else if ladder is an extension of if else statement used to test a series of conditions sequentially, executing the code for the first true condition. A condition is checked only if all previous ones are false. Once a condition is true, its code block executes, and the ladder ends. Example:
      3 min read

    • Switch Statement in C
      C switch statement is a conditional statement that allows you to execute different code blocks based on the value of a variable or an expression. It is often used in place of if-else ladder when there are multiple conditions. Example: [GFGTABS] C //Driver Code Starts{ #include <stdio.h> int ma
      5 min read

    • Using Range in switch Case in C
      You all are familiar with switch case in C, but did you know you can use a range of numbers instead of a single number or character in the case statement? Range in switch case can be useful when we want to run the same set of statements for a range of numbers so that we do not have to write cases se
      2 min read

    • C - Loops
      In C programming, there is often a need for repeating the same part of the code multiple times. For example, to print a text three times, we have to use printf() three times as shown in the code: [GFGTABS] C #include <stdio.h> int main() { printf( "Hello GfG\n"); printf( "Hello
      7 min read

    • C for Loop
      In C programming, the for loop is used to repeatedly execute a block of code as many times as instructed. It uses a variable (loop variable) whose value is used to decide the number of repetitions. It is generally used when we know how many times we want to repeat the code. Let's take a look at an e
      4 min read

    • while Loop in C
      The while loop in C allows a block of code to be executed repeatedly as long as a given condition remains true. It is often used when we want to repeat a block of code till some condition is satisfied. Let's take a look at an example: [GFGTABS] C #include <stdio.h> int main() { int i = 1; // C
      5 min read

    • do...while Loop in C
      The do...while loop is a type of loop in C that executes a block of code until the given condition is satisfied. The feature of do while loops is that unlike the while loop, which checks the condition before executing the loop, the do...while loop ensures that the code inside the loop is executed at
      4 min read

    • For vs. While
      In C, loops are the fundamental part of language that are used to repeat a block of code multiple times. The two most commonly used loops are the for loop and the while loop. Although they achieve the same result, their structure, use cases, and flexibility differ. The below table highlights some pr
      4 min read

    • Continue Statement in C
      The continue statement in C is a jump statement used to skip the current iteration of a loop and continue with the next iteration. It is used inside loops (for, while, or do-while) along with the conditional statements to bypass the remaining statements in the current iteration and move on to next i
      4 min read

    • Break Statement in C
      The break in C is a loop control statement that breaks out of the loop when encountered. It can be used inside loops or switch statements to bring the control out of the block. The break statement can only break out of a single loop at a time. Let's take a look at an example: [GFGTABS] C #include
      5 min read

    • goto Statement in C
      The goto statement in C allows the program to jump to some part of the code, giving you more control over its execution. While it can be useful in certain situations, like error handling or exiting complex loops, it's generally not recommended because it can make the code harder to read and maintain
      4 min read

    C Functions

    • C Functions
      A function in C is a set of statements that when called perform some specific tasks. It is the basic building block of a C program that provides modularity and code reusability. The programming statements of a function are enclosed within { } braces, having certain meanings and performing certain op
      10 min read

    • User-Defined Function in C
      A user-defined function is a type of function in C language that is defined by the user himself to perform some specific task. It provides code reusability and modularity to our program. User-defined functions are different from built-in functions as their working is specified by the user and no hea
      6 min read

    • Parameter Passing Techniques in C
      In C, passing values to a function means providing data to the function when it is called so that the function can use or manipulate that data. Here: Formal Parameters: Variables used in parameter list in a function declaration/definition as placeholders. Also called only parameters.Actual Parameter
      4 min read

    • Function Prototype in C
      In C, a function prototype is a statement that tells the compiler about the function’s name, its return type, numbers, and data types of its parameters. Using this information, the compiler cross-checks function parameters and their data type with function definition and function call. For example,
      6 min read

    • How can I return multiple values from a function?
      In C programming, a function can return only one value directly. However, C also provides several indirect methods in to return multiple values from a function. In this article, we will learn the different ways to return multiple values from a function in C. The most straightforward method to return
      3 min read

    • main Function in C
      The main function is the entry point of a C program. It is a user-defined function where the execution of a program starts. Every C program must contain, and its return value typically indicates the success or failure of the program. In this article, we will learn more about the main function in C.
      5 min read

    • Implicit Return Type int in C
      In C, every function has a return type that indicates the type of value it will return, and it is defined at the time of function declaration or definition. But in C language, it is possible to define functions without mentioning the return type and by default, int is implicitly assumed that the ret
      2 min read

    • Callbacks in C
      A callback is any executable code that is passed as an argument to another code, which is expected to call back (execute) the argument at a given time. In simple terms, a callback is the process of passing a function (executable code) to another function as an argument, and then it is called by the
      4 min read

    • Nested Functions in C
      Nesting of functions refers to placing the definition of the function inside another functions. In C programming, nested functions are not allowed. We can only define a function globally. Example: [GFGTABS] C #include <stdio.h> int main() { void fun(){ printf("GeeksForGeeks"); } fun(
      4 min read

    • Variadic Functions in C
      In C, variadic functions are functions that can take a variable number of arguments. This feature is useful when the number of arguments for a function is unknown. It takes one fixed argument and then any number of arguments can be passed. Let's take a look at an example: [GFGTABS] C #include <st
      5 min read

    • _Noreturn function specifier in C
      In C, the _Noreturn specifier is used to indicate that a function does not return a value. It tells the compiler that the function will either exit the program or enter an infinite loop, so it will never return control to the calling function. This helps the compiler to optimize code and issue warni
      2 min read

    • Predefined Identifier __func__ in C
      Before we start discussing __func__, let us write some code snippets and anticipate the output: C/C++ Code // C program to demonstrate working of a // Predefined Identifier __func__ #include <stdio.h> int main() { // %s indicates that the program will read strings printf("%s", __func
      2 min read

    • C Library math.h Functions
      The math.h header defines various C mathematical functions and one macro. All the functions available in this library take double as an argument and return double as the result. Let us discuss some important C math functions one by one. C Math Functions1. double ceil (double x) The C library functio
      6 min read

    C Arrays & Strings

    • C Arrays
      An array in C is a fixed-size collection of similar data items stored in contiguous memory locations. It can be used to store the collection of primitive data types such as int, char, float, etc., and also derived and user-defined data types such as pointers, structures, etc. Array DeclarationIn C,
      9 min read

    • Properties of Array in C
      An array in C is a fixed-size homogeneous collection of elements stored at a contiguous memory location. It is a derived data type in C that can store elements of different data types such as int, char, struct, etc. It is one of the most popular data types widely used by programmers to solve differe
      8 min read

    • Multidimensional Arrays in C - 2D and 3D Arrays
      A multi-dimensional array in C can be defined as an array that has more than one dimension. Having more than one dimension means that it can grow in multiple directions. Some popular multidimensional arrays include 2D arrays which grows in two dimensions, and 3D arrays which grows in three dimension
      8 min read

    • Initialization of Multidimensional Array in C
      In C, multidimensional arrays are the arrays that contain more than one dimensions. These arrays are useful when we need to store data in a table or matrix-like structure. In this article, we will learn the different methods to initialize a multidimensional array in C. The easiest method for initial
      4 min read

    • Pass Array to Functions in C
      Passing an array to a function allows the function to directly access and modify the original array. In this article, we will learn how to pass arrays to functions in C. In C, arrays are always passed to function as pointers. They cannot be passed by value because of the array decay due to which, wh
      3 min read

    • How to pass a 2D array as a parameter in C?
      A 2D array is essentially an array of arrays, where each element of the main array holds another array. In this article, we will see how to pass a 2D array to a function. The simplest and most common method to pass 2D array to a function is by specifying the parameter as 2D array with row size and c
      3 min read

    • What are the data types for which it is not possible to create an array?
      In C, an array is a collection of variables of the same data type, stored in contiguous memory locations. Arrays can store data of primitive types like integers, characters, and floats, as well as user-defined types like structures. However, there are certain data types for which arrays cannot be di
      2 min read

    • How to pass an array by value in C ?
      In C programming, arrays are always passed as pointers to the function. There are no direct ways to pass the array by value. However, there is trick that allows you to simulate the passing of array by value by enclosing it inside a structure and then passing that structure by value. This will also p
      2 min read

    • Strings in C
      A String in C programming is a sequence of characters terminated with a null character '\0'. The C String is work as an array of characters. The difference between a character array and a C string is that the string in C is terminated with a unique character '\0'. DeclarationDeclaring a string in C
      6 min read

    • Array of Strings in C
      In C, an array of strings is a 2D array where each row contains a sequence of characters terminated by a '\0' NULL character (strings). It is used to store multiple strings in a single array. Let's take a look at an example: [GFGTABS] C #include <stdio.h> int main() { // Creating array of stri
      3 min read

    • What is the difference between single quoted and double quoted declaration of char array?
      In C programming, the way we declare and initialize a char array can differ based on whether we want to use a sequence of characters and strings. They are basically same with difference only of a '\0' NULL character. Double quotes automatically include the null terminator, making the array a string
      2 min read

    • C String Functions
      C language provides various built-in functions that can be used for various operations and manipulations on strings. These string functions make it easier to perform tasks such as string copy, concatenation, comparison, length, etc. The <string.h> header file contains these string functions. T
      7 min read

    C Pointers

    • C Pointers
      A pointer is a variable that stores the memory address of another variable. Instead of holding a direct value, it has the address where the value is stored in memory. This allows us to manipulate the data stored at a specific memory location without actually using its variable. It is the backbone of
      10 min read

    • Pointer Arithmetics in C with Examples
      Pointer Arithmetic is the set of valid arithmetic operations that can be performed on pointers. The pointer variables store the memory address of another variable. It doesn't store any value. Hence, there are only a few operations that are allowed to perform on Pointers in C language. The C pointer
      10 min read

    • C - Pointer to Pointer (Double Pointer)
      In C, double pointers are those pointers which stores the address of another pointer. The first pointer is used to store the address of the variable, and the second pointer is used to store the address of the first pointer. That is why they are also known as a pointer to pointer. Let's take a look a
      5 min read

    • Function Pointer in C
      In C, a function pointer is a type of pointer that stores the address of a function, allowing functions to be passed as arguments and invoked dynamically. It is useful in techniques such as callback functions, event-driven programs, and polymorphism (a concept where a function or operator behaves di
      6 min read

    • How to Declare a Pointer to a Function?
      A pointer to a function is similar to a pointer to a variable. However, instead of pointing to a variable, it points to the address of a function. This allows the function to be called indirectly, which is useful in situations like callback functions or event-driven programming. In this article, we
      2 min read

    • Pointer to an Array | Array Pointer
      A pointer to an array is a pointer that points to the whole array instead of the first element of the array. It considers the whole array as a single unit instead of it being a collection of given elements. Example: [GFGTABS] C #include<stdio.h> int main() { int arr[5] = { 1, 2, 3, 4, 5 }; int
      5 min read

    • Difference between constant pointer, pointers to constant, and constant pointers to constants
      In this article, we will discuss the differences between constant pointer, pointers to constant & constant pointers to constants. Pointers are the variables that hold the address of some other variables, constants, or functions. There are several ways to qualify pointers using const. Pointers to
      3 min read

    • Pointer vs Array in C
      Most of the time, pointer and array accesses can be treated as acting the same, the major exceptions being:   1. the sizeof operator sizeof(array) returns the amount of memory used by all elements in the array sizeof(pointer) only returns the amount of memory used by the pointer variable itself  2.
      1 min read

    • Dangling, Void , Null and Wild Pointers in C
      In C programming pointers are used to manipulate memory addresses, to store the address of some variable or memory location. But certain situations and characteristics related to pointers become challenging in terms of memory safety and program behavior these include Dangling (when pointing to deall
      6 min read

    • Near, Far and Huge Pointers in C
      In older times, the intel processors had 16-bit registers, but the address bus was 20-bits wide. Due to this, CPU registers were not able to hold the entire address at once. As a solution, the memory was divided into segments of 64 kB size, and the near pointers, far pointers, and huge pointers were
      4 min read

    • restrict Keyword in C
      The restrict keyword is a type qualifier that was introduced in the C99 standard. It is used to tell the compiler that a pointer is the only reference or access point to the memory it points to, allowing the compiler to make optimizations based on that information. Let's take a look at an example: [
      3 min read

geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences