SlideShare a Scribd company logo
1 of 8
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

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 (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

Recently uploaded (20)

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 

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; }