SlideShare a Scribd company logo
Strings and Pointers
STRING
 String is a one dimensional array of characters.
 Start with index 0 and end with null character i.e. 0.
 A string may include letter,digits and special
characters(+,-,*,/,$).
Declaration
 A string can be declared in two ways:-
1. Character array-
char color[]=“blue”;
2. Using pointer variable-
const char *colorptr[]=“blue”;
 The first declaration creates a five-element array color
containing the characters ‘b’ , ‘l’ , ‘u’ , ‘e’ and ‘0’.
 The second declaration creates pointer variable colorptr
that points to the character ‘b’ in the string “blue”
somewhere in memory.
 The declaration char color[]=“blue”; could also be
written as:
char color[]={‘b’ , ‘l’ , ‘u’ , ‘e’ , ‘0’};
Passing Strings
 Just as we can pass other kinds of arrays to functions, we
can do so with strings.
 Below is the definition of a function that prints a label and
a call to that function:
 Since label is a character array, and the function
PrintLabel() expects a character array.
 However, if we have a pointer to the character array label,
as in:
char *labelPtr = label;
 Then we can also pass the pointer to the function, as in:
PrintLabel(labelPtr);
 The results are the same.
Why??
 When we declare an array as the parameter to a function, we really
just get a pointer. Plus, arrays are always automatically passed by
reference (e.g., a pointer is passed).
 So, PrintLabel() could have been written in two ways:
void PrintLabel(char the_label[])
{
printf("Label: %sn", the_label);
}
OR
void PrintLabel(char *the_label)
{
printf("Label: %sn", the_label);
}
Various String Manipulation Functions
 The library <cstring> has several common functions for
dealing with strings. The following four are the most useful
ones that we'll discuss:
 strlen(str) :-Returns the number characters in the
string, not including the nul character.
 Output of this program is:
strcmp(str1, str2):- This function takes two strings and
compares them. If the strings are equal, it returns 0. If the
first is greater than the 2nd, then it returns some value
greater than 0. If the first is less than the 2nd, then it
returns some value less than 0.
Output of this program is :-
 The ordering for strings is lexical order based on the ASCII
value of characters. Remember that the ASCII value
of 'A' and 'a' (i.e., upper/lowercase) are not the same.
 An easy way to remember how to use strcmp() to compare
2 strings (let's say a and b) is to use the following
mnemonics:
Want…. Use…
a==b strcmp(a, b) == 0
a<b strcmp(a, b) < 0
a>=b strcmp(a, b) >= 0
 strcpy(dest, source) :-
Copies the contents of source into dest, as in:
Output of this program is:-
Now, the string str1 contains the following:
-------------------------------------------
| s | e | c | o | n | d | 0 | u | e | 0 |
-------------------------------------------
and the word "initvalue" has been overwritten.
Note that it is the first nul character (0) that determines the
end of string.
When using strcpy(), make sure the destination is big enough
to hold new string.
 Aside: An easy way to remember that the destination comes
first is because the order is the same as for assignment, e.g:
dest = source
 Also, strcpy() returns the destination string, but that return
value is often ignored.
 strcat(dest, source) :-
Copies the contents of source onto the end of dest,as in:
Output of this program is :-
Strtok(char s1,const char s2) :-
 A sequence of calls to strtok breaks string s1 into “tokens” –
logical pieces such as words in a line of text- delimited by
characters contained in string s2(delimiter).
 The first call contains s1 as the first argument, and subsequent
calls to continue tokenizing the same string contain NULL as
the first argument.
 A pointer to the current token is returned by each call. If there
are no more tokens when the function is called NULL is
returned.
Consider following program :-
Output of this program is :-
Strings and pointers

More Related Content

What's hot

Enums in c
Enums in cEnums in c
C Programming : Pointers and Strings
C Programming : Pointers and StringsC Programming : Pointers and Strings
C Programming : Pointers and Strings
Selvaraj Seerangan
 
Pointers
PointersPointers
Pointers
sarith divakar
 
structure and union
structure and unionstructure and union
structure and union
student
 
Structure in C
Structure in CStructure in C
Structure in C
Kamal Acharya
 
RECURSION IN C
RECURSION IN C RECURSION IN C
RECURSION IN C
v_jk
 
Enumerated data types in C
Enumerated data types in CEnumerated data types in C
Enumerated data types in C
Arpana shree
 
Tokens in C++
Tokens in C++Tokens in C++
Tokens in C++
Mahender Boda
 
Functions in c language
Functions in c language Functions in c language
Functions in c language
tanmaymodi4
 
Data types in C language
Data types in C languageData types in C language
Data types in C language
kashyap399
 
Pointers in C
Pointers in CPointers in C
Pointers in C
Monishkanungo
 
Pointers in C Programming
Pointers in C ProgrammingPointers in C Programming
Pointers in C Programming
Jasleen Kaur (Chandigarh University)
 
Union in C programming
Union in C programmingUnion in C programming
Union in C programming
Kamal Acharya
 
Pointer in c
Pointer in cPointer in c
Pointer in c
lavanya marichamy
 
Array in c
Array in cArray in c
Array in c
Ravi Gelani
 
Function in C program
Function in C programFunction in C program
Function in C program
Nurul Zakiah Zamri Tan
 
Array in c programming
Array in c programmingArray in c programming
Array in c programming
Mazharul Islam
 
Pointer in C
Pointer in CPointer in C
Pointer in C
Sonya Akter Rupa
 
arrays and pointers
arrays and pointersarrays and pointers
arrays and pointers
Samiksha Pun
 
Formatted input and output
Formatted input and outputFormatted input and output
Formatted input and output
Online
 

What's hot (20)

Enums in c
Enums in cEnums in c
Enums in c
 
C Programming : Pointers and Strings
C Programming : Pointers and StringsC Programming : Pointers and Strings
C Programming : Pointers and Strings
 
Pointers
PointersPointers
Pointers
 
structure and union
structure and unionstructure and union
structure and union
 
Structure in C
Structure in CStructure in C
Structure in C
 
RECURSION IN C
RECURSION IN C RECURSION IN C
RECURSION IN C
 
Enumerated data types in C
Enumerated data types in CEnumerated data types in C
Enumerated data types in C
 
Tokens in C++
Tokens in C++Tokens in C++
Tokens in C++
 
Functions in c language
Functions in c language Functions in c language
Functions in c language
 
Data types in C language
Data types in C languageData types in C language
Data types in C language
 
Pointers in C
Pointers in CPointers in C
Pointers in C
 
Pointers in C Programming
Pointers in C ProgrammingPointers in C Programming
Pointers in C Programming
 
Union in C programming
Union in C programmingUnion in C programming
Union in C programming
 
Pointer in c
Pointer in cPointer in c
Pointer in c
 
Array in c
Array in cArray in c
Array in c
 
Function in C program
Function in C programFunction in C program
Function in C program
 
Array in c programming
Array in c programmingArray in c programming
Array in c programming
 
Pointer in C
Pointer in CPointer in C
Pointer in C
 
arrays and pointers
arrays and pointersarrays and pointers
arrays and pointers
 
Formatted input and output
Formatted input and outputFormatted input and output
Formatted input and output
 

Viewers also liked

Aprendizaje colaborativo
Aprendizaje colaborativoAprendizaje colaborativo
Aprendizaje colaborativoMarihel Netto
 
Векторлар, сандардың стандарт түрі, Деформация
Векторлар, сандардың стандарт түрі, ДеформацияВекторлар, сандардың стандарт түрі, Деформация
Векторлар, сандардың стандарт түрі, Деформацияritulya
 
Retrato paulista oficial (corretor humberto)
Retrato paulista oficial (corretor humberto)Retrato paulista oficial (corretor humberto)
Retrato paulista oficial (corretor humberto)
Humberto Anzzelotti
 
Facebook uygulamaları için performans pazarlama
Facebook uygulamaları için performans pazarlamaFacebook uygulamaları için performans pazarlama
Facebook uygulamaları için performans pazarlamaReklamAction
 
Opportunities at the Alexander von Humboldt Foundation (AvH).
Opportunities at the Alexander von Humboldt Foundation (AvH).Opportunities at the Alexander von Humboldt Foundation (AvH).
Opportunities at the Alexander von Humboldt Foundation (AvH).
Sociedade Brasileira de Pesquisa em Materiais
 
Guia de power
Guia de powerGuia de power
Guia de power
zykro31
 
Apresentacao retrato paulista oficial (corretor humberto)
Apresentacao retrato paulista oficial (corretor humberto)Apresentacao retrato paulista oficial (corretor humberto)
Apresentacao retrato paulista oficial (corretor humberto)
Humberto Anzzelotti
 
Science and technology of multifunctional oxide and ultrananocrystalline diam...
Science and technology of multifunctional oxide and ultrananocrystalline diam...Science and technology of multifunctional oxide and ultrananocrystalline diam...
Science and technology of multifunctional oxide and ultrananocrystalline diam...
Sociedade Brasileira de Pesquisa em Materiais
 
Cümlenin Ögeleri
Cümlenin ÖgeleriCümlenin Ögeleri
Cümlenin Ögeleri
kaston5757
 
Mapas mentales
Mapas mentalesMapas mentales
Mapas mentales
lauracorichi
 
Instagram_Segmentation
Instagram_SegmentationInstagram_Segmentation
Instagram_Segmentation
Academy of Art University
 
01.nakit çek hareketleri
01.nakit çek hareketleri01.nakit çek hareketleri
01.nakit çek hareketleriUmut Karademir
 
Preguntas (3)
Preguntas (3)Preguntas (3)
Preguntas (3)
zykro31
 
Expired Food delivery service
Expired Food delivery serviceExpired Food delivery service
Expired Food delivery service
Academy of Art University
 
Üslü Sayılar
Üslü SayılarÜslü Sayılar
Üslü Sayılar
kaston5757
 
Fraktallar
FraktallarFraktallar
Fraktallar
kaston5757
 
บทที่ 8 หนังสืออิเล็กทรอนิกส์ (e book)
บทที่ 8 หนังสืออิเล็กทรอนิกส์ (e book)บทที่ 8 หนังสืออิเล็กทรอนิกส์ (e book)
บทที่ 8 หนังสืออิเล็กทรอนิกส์ (e book)Masamune Takano
 
SF Giants
SF GiantsSF Giants

Viewers also liked (20)

Morfologi
MorfologiMorfologi
Morfologi
 
Aprendizaje colaborativo
Aprendizaje colaborativoAprendizaje colaborativo
Aprendizaje colaborativo
 
Векторлар, сандардың стандарт түрі, Деформация
Векторлар, сандардың стандарт түрі, ДеформацияВекторлар, сандардың стандарт түрі, Деформация
Векторлар, сандардың стандарт түрі, Деформация
 
Retrato paulista oficial (corretor humberto)
Retrato paulista oficial (corretor humberto)Retrato paulista oficial (corretor humberto)
Retrato paulista oficial (corretor humberto)
 
Facebook uygulamaları için performans pazarlama
Facebook uygulamaları için performans pazarlamaFacebook uygulamaları için performans pazarlama
Facebook uygulamaları için performans pazarlama
 
Opportunities at the Alexander von Humboldt Foundation (AvH).
Opportunities at the Alexander von Humboldt Foundation (AvH).Opportunities at the Alexander von Humboldt Foundation (AvH).
Opportunities at the Alexander von Humboldt Foundation (AvH).
 
Guia de power
Guia de powerGuia de power
Guia de power
 
лекц7
лекц7лекц7
лекц7
 
Apresentacao retrato paulista oficial (corretor humberto)
Apresentacao retrato paulista oficial (corretor humberto)Apresentacao retrato paulista oficial (corretor humberto)
Apresentacao retrato paulista oficial (corretor humberto)
 
Science and technology of multifunctional oxide and ultrananocrystalline diam...
Science and technology of multifunctional oxide and ultrananocrystalline diam...Science and technology of multifunctional oxide and ultrananocrystalline diam...
Science and technology of multifunctional oxide and ultrananocrystalline diam...
 
Cümlenin Ögeleri
Cümlenin ÖgeleriCümlenin Ögeleri
Cümlenin Ögeleri
 
Mapas mentales
Mapas mentalesMapas mentales
Mapas mentales
 
Instagram_Segmentation
Instagram_SegmentationInstagram_Segmentation
Instagram_Segmentation
 
01.nakit çek hareketleri
01.nakit çek hareketleri01.nakit çek hareketleri
01.nakit çek hareketleri
 
Preguntas (3)
Preguntas (3)Preguntas (3)
Preguntas (3)
 
Expired Food delivery service
Expired Food delivery serviceExpired Food delivery service
Expired Food delivery service
 
Üslü Sayılar
Üslü SayılarÜslü Sayılar
Üslü Sayılar
 
Fraktallar
FraktallarFraktallar
Fraktallar
 
บทที่ 8 หนังสืออิเล็กทรอนิกส์ (e book)
บทที่ 8 หนังสืออิเล็กทรอนิกส์ (e book)บทที่ 8 หนังสืออิเล็กทรอนิกส์ (e book)
บทที่ 8 หนังสืออิเล็กทรอนิกส์ (e book)
 
SF Giants
SF GiantsSF Giants
SF Giants
 

Similar to Strings and pointers

C string
C stringC string
string in C
string in Cstring in C
C Programming Unit-3
C Programming Unit-3C Programming Unit-3
C Programming Unit-3
Vikram Nandini
 
Strings
StringsStrings
Strings
Mitali Chugh
 
Unitii string
Unitii stringUnitii string
Unitii string
Sowri Rajan
 
fundamentals of c programming_String.pptx
fundamentals of c programming_String.pptxfundamentals of c programming_String.pptx
fundamentals of c programming_String.pptx
JStalinAsstProfessor
 
[ITP - Lecture 17] Strings in C/C++
[ITP - Lecture 17] Strings in C/C++[ITP - Lecture 17] Strings in C/C++
[ITP - Lecture 17] Strings in C/C++
Muhammad Hammad Waseem
 
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdfSTRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
SowmyaJyothi3
 
introduction to strings in c programming
introduction to strings in c programmingintroduction to strings in c programming
introduction to strings in c programming
mikeymanjiro2090
 
Unit 2
Unit 2Unit 2
Unit 2
TPLatchoumi
 
String notes
String notesString notes
String notes
Prasadu Peddi
 
14 strings
14 strings14 strings
14 strings
Rohit Shrivastava
 
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
 
Strings in c++
Strings in c++Strings in c++
Strings
StringsStrings
Strings
Imad Ali
 
String (Computer programming and utilization)
String (Computer programming and utilization)String (Computer programming and utilization)
String (Computer programming and utilization)
Digvijaysinh Gohil
 
Bsc cs i pic u-4 function, storage class and array and strings
Bsc cs i pic u-4 function, storage class and array and stringsBsc cs i pic u-4 function, storage class and array and strings
Bsc cs i pic u-4 function, storage class and array and strings
Rai University
 
Strings in c mrs.sowmya jyothi
Strings in c mrs.sowmya jyothiStrings in c mrs.sowmya jyothi
Strings in c mrs.sowmya jyothi
Sowmya Jyothi
 
String in programming language in c or c++
String in programming language in c or c++String in programming language in c or c++
String in programming language in c or c++
Azeemaj101
 
Btech i pic u-4 function, storage class and array and strings
Btech i pic u-4 function, storage class and array and stringsBtech i pic u-4 function, storage class and array and strings
Btech i pic u-4 function, storage class and array and strings
Rai University
 

Similar to Strings and pointers (20)

C string
C stringC string
C string
 
string in C
string in Cstring in C
string in C
 
C Programming Unit-3
C Programming Unit-3C Programming Unit-3
C Programming Unit-3
 
Strings
StringsStrings
Strings
 
Unitii string
Unitii stringUnitii string
Unitii string
 
fundamentals of c programming_String.pptx
fundamentals of c programming_String.pptxfundamentals of c programming_String.pptx
fundamentals of c programming_String.pptx
 
[ITP - Lecture 17] Strings in C/C++
[ITP - Lecture 17] Strings in C/C++[ITP - Lecture 17] Strings in C/C++
[ITP - Lecture 17] Strings in C/C++
 
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdfSTRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
 
introduction to strings in c programming
introduction to strings in c programmingintroduction to strings in c programming
introduction to strings in c programming
 
Unit 2
Unit 2Unit 2
Unit 2
 
String notes
String notesString notes
String notes
 
14 strings
14 strings14 strings
14 strings
 
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
 
Strings in c++
Strings in c++Strings in c++
Strings in c++
 
Strings
StringsStrings
Strings
 
String (Computer programming and utilization)
String (Computer programming and utilization)String (Computer programming and utilization)
String (Computer programming and utilization)
 
Bsc cs i pic u-4 function, storage class and array and strings
Bsc cs i pic u-4 function, storage class and array and stringsBsc cs i pic u-4 function, storage class and array and strings
Bsc cs i pic u-4 function, storage class and array and strings
 
Strings in c mrs.sowmya jyothi
Strings in c mrs.sowmya jyothiStrings in c mrs.sowmya jyothi
Strings in c mrs.sowmya jyothi
 
String in programming language in c or c++
String in programming language in c or c++String in programming language in c or c++
String in programming language in c or c++
 
Btech i pic u-4 function, storage class and array and strings
Btech i pic u-4 function, storage class and array and stringsBtech i pic u-4 function, storage class and array and strings
Btech i pic u-4 function, storage class and array and strings
 

Recently uploaded

BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptxBIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
RidwanHassanYusuf
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
TechSoup
 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Henry Hollis
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
Nguyen Thanh Tu Collection
 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
deepaannamalai16
 
Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47
MysoreMuleSoftMeetup
 
A Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two HeartsA Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two Hearts
Steve Thomason
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
Himanshu Rai
 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
imrankhan141184
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
Krassimira Luka
 
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
EduSkills OECD
 
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
TechSoup
 
Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"
National Information Standards Organization (NISO)
 
Skimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S EliotSkimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S Eliot
nitinpv4ai
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
EduSkills OECD
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
zuzanka
 
Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)
nitinpv4ai
 
Data Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsxData Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsx
Prof. Dr. K. Adisesha
 
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
National Information Standards Organization (NISO)
 
How to Predict Vendor Bill Product in Odoo 17
How to Predict Vendor Bill Product in Odoo 17How to Predict Vendor Bill Product in Odoo 17
How to Predict Vendor Bill Product in Odoo 17
Celine George
 

Recently uploaded (20)

BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptxBIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
 
Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47
 
A Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two HeartsA Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two Hearts
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
 
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
 
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
 
Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"
 
Skimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S EliotSkimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S Eliot
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
 
Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)
 
Data Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsxData Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsx
 
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
 
How to Predict Vendor Bill Product in Odoo 17
How to Predict Vendor Bill Product in Odoo 17How to Predict Vendor Bill Product in Odoo 17
How to Predict Vendor Bill Product in Odoo 17
 

Strings and pointers

  • 2. STRING  String is a one dimensional array of characters.  Start with index 0 and end with null character i.e. 0.  A string may include letter,digits and special characters(+,-,*,/,$).
  • 3. Declaration  A string can be declared in two ways:- 1. Character array- char color[]=“blue”; 2. Using pointer variable- const char *colorptr[]=“blue”;
  • 4.  The first declaration creates a five-element array color containing the characters ‘b’ , ‘l’ , ‘u’ , ‘e’ and ‘0’.  The second declaration creates pointer variable colorptr that points to the character ‘b’ in the string “blue” somewhere in memory.  The declaration char color[]=“blue”; could also be written as: char color[]={‘b’ , ‘l’ , ‘u’ , ‘e’ , ‘0’};
  • 5. Passing Strings  Just as we can pass other kinds of arrays to functions, we can do so with strings.  Below is the definition of a function that prints a label and a call to that function:
  • 6.  Since label is a character array, and the function PrintLabel() expects a character array.  However, if we have a pointer to the character array label, as in: char *labelPtr = label;  Then we can also pass the pointer to the function, as in: PrintLabel(labelPtr);  The results are the same. Why??
  • 7.  When we declare an array as the parameter to a function, we really just get a pointer. Plus, arrays are always automatically passed by reference (e.g., a pointer is passed).  So, PrintLabel() could have been written in two ways: void PrintLabel(char the_label[]) { printf("Label: %sn", the_label); } OR void PrintLabel(char *the_label) { printf("Label: %sn", the_label); }
  • 8. Various String Manipulation Functions  The library <cstring> has several common functions for dealing with strings. The following four are the most useful ones that we'll discuss:  strlen(str) :-Returns the number characters in the string, not including the nul character.
  • 9.  Output of this program is:
  • 10. strcmp(str1, str2):- This function takes two strings and compares them. If the strings are equal, it returns 0. If the first is greater than the 2nd, then it returns some value greater than 0. If the first is less than the 2nd, then it returns some value less than 0.
  • 11. Output of this program is :-
  • 12.  The ordering for strings is lexical order based on the ASCII value of characters. Remember that the ASCII value of 'A' and 'a' (i.e., upper/lowercase) are not the same.  An easy way to remember how to use strcmp() to compare 2 strings (let's say a and b) is to use the following mnemonics: Want…. Use… a==b strcmp(a, b) == 0 a<b strcmp(a, b) < 0 a>=b strcmp(a, b) >= 0
  • 13.  strcpy(dest, source) :- Copies the contents of source into dest, as in:
  • 14. Output of this program is:-
  • 15. Now, the string str1 contains the following: ------------------------------------------- | s | e | c | o | n | d | 0 | u | e | 0 | ------------------------------------------- and the word "initvalue" has been overwritten. Note that it is the first nul character (0) that determines the end of string. When using strcpy(), make sure the destination is big enough to hold new string.  Aside: An easy way to remember that the destination comes first is because the order is the same as for assignment, e.g: dest = source  Also, strcpy() returns the destination string, but that return value is often ignored.
  • 16.  strcat(dest, source) :- Copies the contents of source onto the end of dest,as in:
  • 17. Output of this program is :-
  • 18. Strtok(char s1,const char s2) :-  A sequence of calls to strtok breaks string s1 into “tokens” – logical pieces such as words in a line of text- delimited by characters contained in string s2(delimiter).  The first call contains s1 as the first argument, and subsequent calls to continue tokenizing the same string contain NULL as the first argument.  A pointer to the current token is returned by each call. If there are no more tokens when the function is called NULL is returned.
  • 20. Output of this program is :-