C Programming language

C Standard Library Function

Day 1: Introduction and brief history of C Programming language

Day 1: Advantages and Disadvantages of C, C Keywords, Data type modifiers in C

Day 1: Data types in C Programming language

Day 1: Secondary data types, Primitive and Non-primitive data types

Day 1: C Variables, C Constant, Format Specifiers in C

Day 2: Write first C program

Day 2: Flow of C program with example, main(), printf(), scanf()

Day 2: Operaters in C Programming language, Arithmetic operators

Day 2: Relational operators and Logical Operators in C Programming language

Day 2: Assignment, Increments and Decrement Operators in C Programming language

Day 3: Conditional statement: if else statement in C Programming language

Day 3: Conditional statement: switch statement in C Programming language

Day 3: Jump statements: return statement in C Programming language

Day 3: Jump statements: go to statement in C Programming language

Day 3: Jump statements: break statement in C Programming language

Day 3: Jump statements: continue statement in C Programming language

Day 4: Loops OR Iteration statement in C Programming language: for Loop

Day 4: Loops OR Iteration statement in C Programming language: while Loop

Day 4: Loops OR Iteration statement in C Programming language: do while Loop

Day 5: Array in C Programming language

Day 5: Access elements of Array in C Programming language

Day 5: One dimensional Array representation in memory using C Programming language

Day 5: Two dimensional Array representation in memory using C Programming language

Day 5: Multidimensional Array in C Programming language

Day 6: Function in C Programming language

Day 6: Definition, Declaration and Calling a Function in C Programming language

Day 6: Passing array to a function in C Programming language

Day 6: Calling Function in C Programming language : Call by value

Day 6: Calling Function in C Programming language : Call by reference

Day 6: Recursive Function in C Programming language

Day 6: Adding function to the library in C Programming language

Day 7: Pointer in C Programming language, How to use Pointer, Pointer declaration

Day 7: NULL Pointers in C Programming language

Day 7: Array of Pointers in C Programming language

Day 7: Pointer arithmetic in C Programming language

Day 7: Pointer to Pointer in C Programming language

Day 7: Pointer to Function in C Programming language: Passing pointers to functions

Day 7: Pointer to Function in C Programming language: Return pointer from functions

Day 8: Strings in C Programming language, Declaring String in C Programming language

Day 8: String functions in C Programming language

Introduction of Structure

Accessing the members of Structure

Structure With typedef Keyword and Use of sizeof function

Example of Structure

Dynamic memory allocation in C: Introduction

adplus-dvertising
Day 7 Array of Pointers in C Programming language
Previous Home Next

Let us consider the following example, which makes use of an array of 3 integers:

#include <stdio.h>

const int MAX = 3;
void main ()
{
   int  var[] = {12, 400, 800};
   int i;
 
   for (i = 0; i < MAX; i++)
   {
      printf("Value of var[%d] = %d\n", i, var[i] );
   }
}
Output

Value of var[0] = 12

Value of var[1] = 400

Value of var[2] = 800

# Following is the declaration of an array of pointers to an integer

There may be a situation when we want to maintain an array, which can store pointers to an int or char or any other data type available.

int *ptr[MAX];

Declares ptr as an array of MAX integer pointers. Thus, each element in ptr, now holds a pointer to an int value.

#include <stdio.h>
 
const int MAX = 3;
 
int main ()
{
   int  var[] = {12, 400, 800};
   int j, *ptr[MAX]; 
   for ( j = 0; j < MAX; j++)
   {
      ptr[j] = &var[j]; /* assign the address of integer. */
   }
   for ( j = 0; j < MAX; j++)
   {
      printf("Value of var[%d] = %d\n", j, *ptr[j] );/* value of variable */
	  printf("Value of var[%d] = %d\n", j, ptr[j] ); /* address of variable */
   }
   return 0;
}
Output

Value of var[0] = 10

Value of var[0] = 1570429008

Value of var[1] = 100

Value of var[1] = 1570429012

Value of var[2] = 200

Value of var[2] = 1570429016

# Use an array of pointers to character to store a list of strings as follows:

#include <stdio.h>
 
const int MAX = 4;
 
int main ()
{
   char *student[] = {
                   "ABC",
                   "XYZ",
                   "PQR",
                   "MNO",
   };
   int i = 0;

   for ( i = 0; i < MAX; i++)
   {
      printf("Name of student[%d] = %s\n", i, student[i] );
	  printf("Address value of student[%d] name = %d\n", i, *student[i] );
   }
   return 0;
}
Output

Name of student[0] = ABC

Address value of student[0] name = 65

Name of student[1] = XYZ

Address value of student[1] name = 88

Name of student[2] = PQR

Address value of student[2] name = 80

Name of student[3] = MNO

Address value of student[3] name = 77

Previous Home Next