100% tevredenheidsgarantie Direct beschikbaar na je betaling Lees online óf als PDF Geen vaste maandelijkse kosten 4,6 TrustPilot
logo-home
Samenvatting

Summary strings and pointers

Beoordeling
-
Verkocht
-
Pagina's
35
Geüpload op
18-01-2026
Geschreven 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

Instelling
Vak











Oeps! We kunnen je document nu niet laden. Probeer het nog eens of neem contact op met support.

Geschreven voor

Instelling
Studie
Onbekend
Vak

Documentinformatie

Geüpload op
18 januari 2026
Aantal pagina's
35
Geschreven in
2025/2026
Type
Samenvatting

Onderwerpen

Voorbeeld van de inhoud

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);
}
€6,65
Krijg toegang tot het volledige document:

100% tevredenheidsgarantie
Direct beschikbaar na je betaling
Lees online óf als PDF
Geen vaste maandelijkse kosten

Maak kennis met de verkoper
Seller avatar
tabassumy

Ook beschikbaar in voordeelbundel

Maak kennis met de verkoper

Seller avatar
tabassumy
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
Nieuw op Stuvia
Lid sinds
2 weken
Aantal volgers
0
Documenten
17
Laatst verkocht
-

0,0

0 beoordelingen

5
0
4
0
3
0
2
0
1
0

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via Bancontact, iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo eenvoudig kan het zijn.”

Alisha Student

Veelgestelde vragen