SlideShare a Scribd company logo
String
String is an array of characters.
char name[]={‘R', ‘A', ‘V', ‘I', ‘N', '0’};
NULL character (0) will automatically be inserted at the end of the
string.
'0' represents the end of the string. It is also referred as String
terminator & Null Character.
String Functions
• Strlen – Find out length of the string
• Strcat – Concatenates of two string
• Strcmp – Comparing of two string
• Strcpy – Copies the string
Pointer
• Pointer is a variable that contain the address of other variable.
• A Pointer in C is used to allocate memory dynamically i.e. at run
time. The pointer variable might be belonging to any of the data type
such as int, float, char, double, short etc.
• Pointer Syntax : data_type *var_name; Example : int *p; char *p;
• Where, * is used to denote that “p” is pointer variable and not a
normal variable.
KEY POINTS TO REMEMBER ABOUT POINTERS IN C:
• Normal variable stores the value whereas pointer variable stores the
address of the variable.
• The content of the C pointer always be a whole number i.e. address.
• Always C pointer is initialized to null, i.e. int *p = null.
• The value of null pointer is 0.
• & symbol is used to get the address of the variable.
• * symbol is used to get the value of the variable that the pointer is
pointing to.
• If a pointer in C is assigned to NULL, it means it is pointing to nothing.
Example
#include <stdio.h>
Void main()
{
int *ptr, q;
q = 50;
/* address of q is assigned to ptr */
ptr = &q;
/* display q's value using ptr variable */
printf("%d", *ptr);
}
/*C program to create, initialize, assign and access a pointer variable.*/
#include <stdio.h>
int main()
{
int num; /*declaration of integer variable*/
int *pNum; /*declaration of integer pointer*/
pNum=& num; /*assigning address of num*/
num=100; /*assigning 100 to variable num*/
//access value and address using variable num
printf("Using variable num:n");
printf("value of num: %dnaddress of num: %un",num,&num);
//access value and address using pointer variable num
printf("Using pointer variable:n");
printf("value of num: %dnaddress of num: %un",*pNum,pNum);
return 0;
}

More Related Content

Similar to NRG 106_Session 6_String&Pointer.pptx

Pointers
PointersPointers
Pointers
PreethyJemima
 
Pointers in C Language
Pointers in C LanguagePointers in C Language
Pointers in C Language
madan reddy
 
PSPC--UNIT-5.pdf
PSPC--UNIT-5.pdfPSPC--UNIT-5.pdf
PSPC--UNIT-5.pdf
ArshiniGubbala3
 
Unit-I Pointer Data structure.pptx
Unit-I Pointer Data structure.pptxUnit-I Pointer Data structure.pptx
Unit-I Pointer Data structure.pptx
ajajkhan16
 
20.C++Pointer.pptx
20.C++Pointer.pptx20.C++Pointer.pptx
20.C++Pointer.pptx
AtharvPotdar2
 
Pointer introduction day1
Pointer introduction day1Pointer introduction day1
Pointer introduction day1
Bhuvana Gowtham
 
COM1407: Working with Pointers
COM1407: Working with PointersCOM1407: Working with Pointers
COM1407: Working with Pointers
Hemantha Kulathilake
 
Lesson in Strings for C Programming Lessons
Lesson in Strings for C Programming LessonsLesson in Strings for C Programming Lessons
Lesson in Strings for C Programming Lessons
JamesChristianGadian
 
Pointers in c - Mohammad Salman
Pointers in c - Mohammad SalmanPointers in c - Mohammad Salman
Pointers in c - Mohammad Salman
MohammadSalman129
 
Pointer in c
Pointer in cPointer in c
Pointer in c
Imamul Kadir
 
Pointer
PointerPointer
c ppt.pdf
c ppt.pdfc ppt.pdf
c ppt.pdf
GLOWTAMIL
 
Unit 8. Pointers
Unit 8. PointersUnit 8. Pointers
Unit 8. Pointers
Ashim Lamichhane
 
introduction to strings in c programming
introduction to strings in c programmingintroduction to strings in c programming
introduction to strings in c programming
mikeymanjiro2090
 
C- language Lecture 5
C- language Lecture 5C- language Lecture 5
C- language Lecture 5
Hatem Abd El-Salam
 
Pointers C programming
Pointers  C programmingPointers  C programming
Pointers C programming
Appili Vamsi Krishna
 
pointers.pptx
pointers.pptxpointers.pptx
pointers.pptx
s170883BesiVyshnavi
 
Pointers
PointersPointers
Pointers
Prasadu Peddi
 

Similar to NRG 106_Session 6_String&Pointer.pptx (20)

Pointers.pdf
Pointers.pdfPointers.pdf
Pointers.pdf
 
Pointers
PointersPointers
Pointers
 
Pointers in C Language
Pointers in C LanguagePointers in C Language
Pointers in C Language
 
PSPC--UNIT-5.pdf
PSPC--UNIT-5.pdfPSPC--UNIT-5.pdf
PSPC--UNIT-5.pdf
 
Unit-I Pointer Data structure.pptx
Unit-I Pointer Data structure.pptxUnit-I Pointer Data structure.pptx
Unit-I Pointer Data structure.pptx
 
20.C++Pointer.pptx
20.C++Pointer.pptx20.C++Pointer.pptx
20.C++Pointer.pptx
 
Pointer introduction day1
Pointer introduction day1Pointer introduction day1
Pointer introduction day1
 
COM1407: Working with Pointers
COM1407: Working with PointersCOM1407: Working with Pointers
COM1407: Working with Pointers
 
Pointers
PointersPointers
Pointers
 
Lesson in Strings for C Programming Lessons
Lesson in Strings for C Programming LessonsLesson in Strings for C Programming Lessons
Lesson in Strings for C Programming Lessons
 
Pointers in c - Mohammad Salman
Pointers in c - Mohammad SalmanPointers in c - Mohammad Salman
Pointers in c - Mohammad Salman
 
Pointer in c
Pointer in cPointer in c
Pointer in c
 
Pointer
PointerPointer
Pointer
 
c ppt.pdf
c ppt.pdfc ppt.pdf
c ppt.pdf
 
Unit 8. Pointers
Unit 8. PointersUnit 8. Pointers
Unit 8. Pointers
 
introduction to strings in c programming
introduction to strings in c programmingintroduction to strings in c programming
introduction to strings in c programming
 
C- language Lecture 5
C- language Lecture 5C- language Lecture 5
C- language Lecture 5
 
Pointers C programming
Pointers  C programmingPointers  C programming
Pointers C programming
 
pointers.pptx
pointers.pptxpointers.pptx
pointers.pptx
 
Pointers
PointersPointers
Pointers
 

More from KRIPABHARDWAJ1

gis assgnmnt.pptx
gis assgnmnt.pptxgis assgnmnt.pptx
gis assgnmnt.pptx
KRIPABHARDWAJ1
 
NRG 106_Session 4_CLanguage.pptx
NRG 106_Session 4_CLanguage.pptxNRG 106_Session 4_CLanguage.pptx
NRG 106_Session 4_CLanguage.pptx
KRIPABHARDWAJ1
 
NRG 106_Session 2_FlowCharts.pptx
NRG 106_Session 2_FlowCharts.pptxNRG 106_Session 2_FlowCharts.pptx
NRG 106_Session 2_FlowCharts.pptx
KRIPABHARDWAJ1
 
NRG 106_Session 1_History.pptx
NRG 106_Session 1_History.pptxNRG 106_Session 1_History.pptx
NRG 106_Session 1_History.pptx
KRIPABHARDWAJ1
 
Dams- Politics of Displacement (Domestic) (1).pptx
Dams- Politics of Displacement (Domestic) (1).pptxDams- Politics of Displacement (Domestic) (1).pptx
Dams- Politics of Displacement (Domestic) (1).pptx
KRIPABHARDWAJ1
 
Rain Water Harvesting.pptx
Rain Water Harvesting.pptxRain Water Harvesting.pptx
Rain Water Harvesting.pptx
KRIPABHARDWAJ1
 
FINAL PPT (HYDROLOGY) WATER HARVESTING.pptx
FINAL PPT  (HYDROLOGY) WATER HARVESTING.pptxFINAL PPT  (HYDROLOGY) WATER HARVESTING.pptx
FINAL PPT (HYDROLOGY) WATER HARVESTING.pptx
KRIPABHARDWAJ1
 
SOURCES OF POPULATION DATA.pptx
SOURCES OF POPULATION DATA.pptxSOURCES OF POPULATION DATA.pptx
SOURCES OF POPULATION DATA.pptx
KRIPABHARDWAJ1
 
French & Industrial Rev..pptx
French & Industrial Rev..pptxFrench & Industrial Rev..pptx
French & Industrial Rev..pptx
KRIPABHARDWAJ1
 
Landslide.pptx
Landslide.pptxLandslide.pptx
Landslide.pptx
KRIPABHARDWAJ1
 

More from KRIPABHARDWAJ1 (10)

gis assgnmnt.pptx
gis assgnmnt.pptxgis assgnmnt.pptx
gis assgnmnt.pptx
 
NRG 106_Session 4_CLanguage.pptx
NRG 106_Session 4_CLanguage.pptxNRG 106_Session 4_CLanguage.pptx
NRG 106_Session 4_CLanguage.pptx
 
NRG 106_Session 2_FlowCharts.pptx
NRG 106_Session 2_FlowCharts.pptxNRG 106_Session 2_FlowCharts.pptx
NRG 106_Session 2_FlowCharts.pptx
 
NRG 106_Session 1_History.pptx
NRG 106_Session 1_History.pptxNRG 106_Session 1_History.pptx
NRG 106_Session 1_History.pptx
 
Dams- Politics of Displacement (Domestic) (1).pptx
Dams- Politics of Displacement (Domestic) (1).pptxDams- Politics of Displacement (Domestic) (1).pptx
Dams- Politics of Displacement (Domestic) (1).pptx
 
Rain Water Harvesting.pptx
Rain Water Harvesting.pptxRain Water Harvesting.pptx
Rain Water Harvesting.pptx
 
FINAL PPT (HYDROLOGY) WATER HARVESTING.pptx
FINAL PPT  (HYDROLOGY) WATER HARVESTING.pptxFINAL PPT  (HYDROLOGY) WATER HARVESTING.pptx
FINAL PPT (HYDROLOGY) WATER HARVESTING.pptx
 
SOURCES OF POPULATION DATA.pptx
SOURCES OF POPULATION DATA.pptxSOURCES OF POPULATION DATA.pptx
SOURCES OF POPULATION DATA.pptx
 
French & Industrial Rev..pptx
French & Industrial Rev..pptxFrench & Industrial Rev..pptx
French & Industrial Rev..pptx
 
Landslide.pptx
Landslide.pptxLandslide.pptx
Landslide.pptx
 

Recently uploaded

The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.
ViralQR
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 

Recently uploaded (20)

The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 
Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 

NRG 106_Session 6_String&Pointer.pptx

  • 2. String is an array of characters. char name[]={‘R', ‘A', ‘V', ‘I', ‘N', '0’}; NULL character (0) will automatically be inserted at the end of the string. '0' represents the end of the string. It is also referred as String terminator & Null Character.
  • 3. String Functions • Strlen – Find out length of the string • Strcat – Concatenates of two string • Strcmp – Comparing of two string • Strcpy – Copies the string
  • 5. • Pointer is a variable that contain the address of other variable. • A Pointer in C is used to allocate memory dynamically i.e. at run time. The pointer variable might be belonging to any of the data type such as int, float, char, double, short etc. • Pointer Syntax : data_type *var_name; Example : int *p; char *p; • Where, * is used to denote that “p” is pointer variable and not a normal variable.
  • 6. KEY POINTS TO REMEMBER ABOUT POINTERS IN C: • Normal variable stores the value whereas pointer variable stores the address of the variable. • The content of the C pointer always be a whole number i.e. address. • Always C pointer is initialized to null, i.e. int *p = null. • The value of null pointer is 0. • & symbol is used to get the address of the variable. • * symbol is used to get the value of the variable that the pointer is pointing to. • If a pointer in C is assigned to NULL, it means it is pointing to nothing.
  • 7. Example #include <stdio.h> Void main() { int *ptr, q; q = 50; /* address of q is assigned to ptr */ ptr = &q; /* display q's value using ptr variable */ printf("%d", *ptr); }
  • 8. /*C program to create, initialize, assign and access a pointer variable.*/ #include <stdio.h> int main() { int num; /*declaration of integer variable*/ int *pNum; /*declaration of integer pointer*/ pNum=& num; /*assigning address of num*/ num=100; /*assigning 100 to variable num*/ //access value and address using variable num printf("Using variable num:n"); printf("value of num: %dnaddress of num: %un",num,&num); //access value and address using pointer variable num printf("Using pointer variable:n"); printf("value of num: %dnaddress of num: %un",*pNum,pNum); return 0; }