100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.6 TrustPilot
logo-home
Summary

Summary strings and pointers

Rating
-
Sold
-
Pages
35
Uploaded on
18-01-2026
Written in
2025/2026

This document contains c programming key concepts like strings and pointers . The notes are well structured , easy to understand , and helpful for quick revision












Whoops! We can’t load your doc right now. Try again or contact support.

Document information

Uploaded on
January 18, 2026
Number of pages
35
Written in
2025/2026
Type
Summary

Content preview

UNIT IV POINTERS & STRINGS
Syllabus: Introduction to Pointers, dereferencing and address operators, pointer and address
arithmetic, array manipulation using pointers. Introduction to Strings: String Operations and
String functions.

Introduction to pointers
Consider the below declaration:
 int i = 3;
The above declaration tells the C compiler for:
1. Reserve space in memory to hold the integer value
2. Assign a name ‘i’ with this memory location. This is called as a variable
3. After that, store the value ‘3’ at this location
The representation of above 3 steps in memory by the memory map is shown given below:




Example 1: To print the address of a variableSource code:




Output:

,Definition of pointer:
The pointer is a variable which stores the address of another variable. This variable can be of
type int, char, array, function, or any other pointer. The size of the pointer depends on the
architecture. However, in 32-bit architecture the size of a pointer is 4 bytes.
Syntax and examples of pointers in C

 data_type *pointer_variable_name;
Examples:
1. int *ptr_in; // pointer to an integer
2. char *ptr_ch ; // pointer to a character
3. double *ptr_dbl; // pointer to a double
4. float *ptr_fl; // pointer to a float
How to Use Pointers in C
1. Declare a pointer variable.
2. A variable’s address is assigned to a pointer variable using the & operator.
3. Use the address in the pointer variable to get the value by using the *(asterisk) operator,
which returns the variable's value at the address indicated by its argument.
Example 2: A program to create pointer variable




Output:

,Extended Pointers




Output:




Finding Size of pointer
The declaration char *ch means that ‘ch’ is going to contain the address of a char value.
Similarly, float *f means that ‘f’ going to contain the address of floating-point value.
The printf() would report the size of each pointer as 2Bytes, 4Bytes or 8Bytes based on
computer architecture 16-bit, 32-bit or 64-bit.
Note: This program I am executing on my machine is “64-bit operating system, x64-based
processor”. Therefore, the size is 8Bytes

, Source code:
#include<stdio.h>
void main()
{
int *ptr1;
char *ptr2;
float *ptr3;
double *ptr4;
printf("The size of integer pointer is %i", sizeof(ptr1));
printf("\nThe size of character pointer is %i", sizeof(ptr2));
printf("\nThe size of float pointer is %i", sizeof(ptr3));
printf("\nThe size of double pointer is %i", sizeof(ptr4));
}
Output:




Types of pointers
These are the following types of pointers:
1. NULL pointer
2. void pointer
3. Wild pointer
4. Dangling pointer
NULL Pointer
 A null pointer is a type of pointer created by assigning a null value to the pointer. A null
pointer can be of any data type.
 It has a value of 0 in it.
 It indicates that the pointer is not intended to point to an accessible memory location.
 Dereferencing null pointer results in undefined behavior, i.e., if you try to access as *ptr
(where ptr is a NULL pointer), it will result in a null pointer exception.
Example 6: A program to create a NULL pointer
Source code:
#include<stdio.h>
void main()
{
int *ptr1 = NULL;
printf("The value of ptr1 variable is %d", ptr1);
printf("\nThe address of ptr1 variable is %x", &ptr1);
printf("The dereferencing of ptr1 variable is %d", *ptr1);
}
£5.77
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
tabassumy

Also available in package deal

Thumbnail
Package deal
C programming
-
5 2026
£ 28.83 More info

Get to know the seller

Seller avatar
tabassumy
View profile
Follow You need to be logged in order to follow users or courses
Sold
New on Stuvia
Member since
2 weeks
Number of followers
0
Documents
17
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these revision notes.

Didn't get what you expected? Choose another document

No problem! You can straightaway pick a different document that better suits what you're after.

Pay as you like, start learning straight away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and smashed it. It really can be that simple.”

Alisha Student

Frequently asked questions