SlideShare a Scribd company logo
Presentation on string.h
String.h- This header file defines several  functions to manipulate C strings and arrays. Functions declared in string.h are extremely popular since as a part of the C standard library, they are  guaranteed to work on any platform  which supports C Some of its functions are defined below .
Memcpy:-  Use Copy block of memory   SYNOPSIS #include <string.h> void *memcpy(void *s1, const void *s2, size_tn);   DESCRIPTION The memcpy() function copies n bytes from the object pointed to by s2 into the object pointed to by s1. If copying takes place between objects that overlap, the behaviour is undefined.   RETURN VALUE The memcpy() function returns s1; no return value is reserved to indicate an error.
Example /* memcpy example */ #include <stdio.h> #include <string.h>  int main () {   char str1[]="Sample string";  char str2[40];  char str3[40]; memcpy (str2,str1,strlen(str1)+1); memcpy (str3,"copy successful",16); printf ("str1: %sstr2: %sstr3: %s",str1,str2,str3);   return 0; } Output str1: Sample string str2: Sample string str3: copy successful
memmove memmove Memmove:- Use Move block of memory SYNOPSIS #include <string.h> void *memmove(void *s1, const void *s2, size_tn);   DESCRIPTION The memmove() function copies n bytes from the object pointed to by s2 into the object pointed  to by s1. Copying takes place as if the n bytes from the object pointed to by s2 are first copied  into a temporary array of n bytes that does not overlap the objects pointed to by s1 and s2,  and then the n bytes from the temporary array are copied into the object pointed to by s1.   RETURN VALUE The memmove() function returns s1; no return value is reserved to indicate an error.
Example /* memmove example */  #include <stdio.h>  #include <string.h> int main ()  {     char str[] = "memmove can be veryuseful......"; memmove (str+20,str+15,11);     puts (str);     return 0; }} } Output memmove can be very very useful.
Memcmp :- Use Compare two blocks of memory SYNOPSIS #include <string.h> intmemcmp(const void *s1, const void *s2, size_tn);   DESCRIPTION The memcmp() function compares the first n bytes of the object pointed to by s1 to the first  nbytes of the object pointed to by s2. The sign of a non-zero return value is determined by the sign of the difference between the values of the first pair of bytes that differ in the objects  being compared.    RETURN VALUE The memcmp() function returns an integer greater than, equal to or less than 0, if the object  pointed to by s1 is greater than, equal to or less than the object pointed to by s2 respectively.
Example /* memcmp example */ #include <stdio.h> #include <string.h>   int main () {   char str1[256];   char str2[256]; int n; size_t len1, len2; printf ("Enter a sentence: "); gets(str1); printf ("Enter another sentence: "); gets(str2);   len1=strlen(str1);   len2=strlen(str2);   n=memcmp ( str1, str2, len1>len2?len1:len2 );   if (n>0) printf ("'%s' is greater than '%s'.",str1,str2);   else if (n<0) printf ("'%s' is less than '%s'.",str1,str2);   else printf ("'%s' is the same as '%s'.",str1,str2);   return 0; } Output Enter a sentence: building Enter another sentence: book 'building' is greater than 'book'
Memset:- Use Fill block of memory SYNOPSIS #include <string.h> void *memset(void *s, intc, size_tn);   DESCRIPTION The memset() function copies c (converted to an unsigned char) into each of the first n bytes  of the object pointed to by s.   RETURN VALUE The memset() function returns s; no return value is reserved to indicate an error.
Example /* memset example */ #include <stdio.h> #include <string.h>   int main () {   char str[] = "almost every programmer should know memset!"; memset (str,'-',6);   puts (str);   return 0; } Output ------ every programmer should know memset!
Memchr Use Locate character in block of memory  SYNOPSIS #include <string.h> void *memchr(const void *s, intc, size_tn);  DESCRIPTION The memchr() function locates the first occurrence of c (converted to an unsigned char) in the  initial n bytes (each interpreted as unsigned char) of the object pointed to by s.   RETURN VALUE The memchr() function returns a pointer to the located byte, or a null pointer if the byte does  not occur in the object.
Example /* memchr example */ #include <stdio.h> #include <string.h>   int main () {   char * pch;   char str[] = "Example string"; pch = (char*) memchr (str, 'p', strlen(str));   if (pch!=NULL) printf ("'p' found at position %d.", pch-str+1);   else printf ("'p' not found.");   return 0; } Output 'p' found at position 5.
Thanks  for watching  .Hope u like it….. By :- NISHANK

More Related Content

What's hot

Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4
Saranya saran
 
C++ 11 Features
C++ 11 FeaturesC++ 11 Features
C++ 11 Features
Jan Rüegg
 
C programming(Part 1)
C programming(Part 1)C programming(Part 1)
C programming(Part 1)
SURBHI SAROHA
 
Strings
StringsStrings
Strings
Saranya saran
 
C++11 & C++14
C++11 & C++14C++11 & C++14
C++11 & C++14
CyberPlusIndia
 
String Handling in c++
String Handling in c++String Handling in c++
String Handling in c++
Fahim Adil
 
Maintainable go
Maintainable goMaintainable go
Maintainable go
Yu-Shuan Hsieh
 
Modern C++
Modern C++Modern C++
Modern C++
Michael Clark
 
14 strings
14 strings14 strings
14 strings
Rohit Shrivastava
 
7 functions
7  functions7  functions
7 functions
MomenMostafa
 
4 Type conversion functions
4 Type conversion functions4 Type conversion functions
4 Type conversion functions
Docent Education
 
Headerfiles
HeaderfilesHeaderfiles
Headerfiles
archikabhatia
 
C++11: Feel the New Language
C++11: Feel the New LanguageC++11: Feel the New Language
C++11: Feel the New Language
mspline
 
4 operators, expressions &amp; statements
4  operators, expressions &amp; statements4  operators, expressions &amp; statements
4 operators, expressions &amp; statements
MomenMostafa
 
8 arrays and pointers
8  arrays and pointers8  arrays and pointers
8 arrays and pointers
MomenMostafa
 
1 introducing c language
1  introducing c language1  introducing c language
1 introducing c language
MomenMostafa
 
array, function, pointer, pattern matching
array, function, pointer, pattern matchingarray, function, pointer, pattern matching
array, function, pointer, pattern matching
Shakila Mahjabin
 
Permute
PermutePermute
Pointers in C/C++ Programming
Pointers in C/C++ ProgrammingPointers in C/C++ Programming
Pointers in C/C++ Programming
Faisal Shahzad Khan
 
Dd3.15 thru-3.21-advanced-functions
Dd3.15 thru-3.21-advanced-functionsDd3.15 thru-3.21-advanced-functions
Dd3.15 thru-3.21-advanced-functions
temkin abdlkader
 

What's hot (20)

Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4
 
C++ 11 Features
C++ 11 FeaturesC++ 11 Features
C++ 11 Features
 
C programming(Part 1)
C programming(Part 1)C programming(Part 1)
C programming(Part 1)
 
Strings
StringsStrings
Strings
 
C++11 & C++14
C++11 & C++14C++11 & C++14
C++11 & C++14
 
String Handling in c++
String Handling in c++String Handling in c++
String Handling in c++
 
Maintainable go
Maintainable goMaintainable go
Maintainable go
 
Modern C++
Modern C++Modern C++
Modern C++
 
14 strings
14 strings14 strings
14 strings
 
7 functions
7  functions7  functions
7 functions
 
4 Type conversion functions
4 Type conversion functions4 Type conversion functions
4 Type conversion functions
 
Headerfiles
HeaderfilesHeaderfiles
Headerfiles
 
C++11: Feel the New Language
C++11: Feel the New LanguageC++11: Feel the New Language
C++11: Feel the New Language
 
4 operators, expressions &amp; statements
4  operators, expressions &amp; statements4  operators, expressions &amp; statements
4 operators, expressions &amp; statements
 
8 arrays and pointers
8  arrays and pointers8  arrays and pointers
8 arrays and pointers
 
1 introducing c language
1  introducing c language1  introducing c language
1 introducing c language
 
array, function, pointer, pattern matching
array, function, pointer, pattern matchingarray, function, pointer, pattern matching
array, function, pointer, pattern matching
 
Permute
PermutePermute
Permute
 
Pointers in C/C++ Programming
Pointers in C/C++ ProgrammingPointers in C/C++ Programming
Pointers in C/C++ Programming
 
Dd3.15 thru-3.21-advanced-functions
Dd3.15 thru-3.21-advanced-functionsDd3.15 thru-3.21-advanced-functions
Dd3.15 thru-3.21-advanced-functions
 

Similar to String .h

Lecture 15_Strings and Dynamic Memory Allocation.pptx
Lecture 15_Strings and  Dynamic Memory Allocation.pptxLecture 15_Strings and  Dynamic Memory Allocation.pptx
Lecture 15_Strings and Dynamic Memory Allocation.pptx
JawadTanvir
 
C++ Programming Homework Help
C++ Programming Homework HelpC++ Programming Homework Help
C++ Programming Homework Help
C++ Homework Help
 
Linked list
Linked listLinked list
Linked list
somuinfo123
 
Savitch Ch 08
Savitch Ch 08Savitch Ch 08
Savitch Ch 08
Terry Yoast
 
C aptitude questions
C aptitude questionsC aptitude questions
C aptitude questions
Srikanth
 
C - aptitude3
C - aptitude3C - aptitude3
C - aptitude3
Srikanth
 
Unit 2
Unit 2Unit 2
Unit 2
TPLatchoumi
 
Unitii string
Unitii stringUnitii string
Unitii string
Sowri Rajan
 
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...
ssuserd6b1fd
 
booksoncprogramminglanguage-anintroductiontobeginnersbyarunumrao4-21101016591...
booksoncprogramminglanguage-anintroductiontobeginnersbyarunumrao4-21101016591...booksoncprogramminglanguage-anintroductiontobeginnersbyarunumrao4-21101016591...
booksoncprogramminglanguage-anintroductiontobeginnersbyarunumrao4-21101016591...
GkhanGirgin3
 
Savitch ch 08
Savitch ch 08Savitch ch 08
Savitch ch 08
Terry Yoast
 
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
 
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
 
Functions torage class and array and strings-
Functions torage class and array and strings-Functions torage class and array and strings-
Functions torage class and array and strings-
aneebkmct
 
Imugi: Compiler made with Python
Imugi: Compiler made with PythonImugi: Compiler made with Python
Imugi: Compiler made with Python
Han Lee
 
CPP Homework Help
CPP Homework HelpCPP Homework Help
CPP Homework Help
C++ Homework Help
 
Diploma ii cfpc u-4 function, storage class and array and strings
Diploma ii  cfpc u-4 function, storage class and array and stringsDiploma ii  cfpc u-4 function, storage class and array and strings
Diploma ii cfpc u-4 function, storage class and array and strings
Rai University
 
06 -working_with_strings
06  -working_with_strings06  -working_with_strings
06 -working_with_strings
Hector Garzo
 
Mcai pic u 4 function, storage class and array and strings
Mcai pic u 4 function, storage class and array and stringsMcai pic u 4 function, storage class and array and strings
Mcai pic u 4 function, storage class and array and strings
Rai University
 
function, storage class and array and strings
 function, storage class and array and strings function, storage class and array and strings
function, storage class and array and strings
Rai University
 

Similar to String .h (20)

Lecture 15_Strings and Dynamic Memory Allocation.pptx
Lecture 15_Strings and  Dynamic Memory Allocation.pptxLecture 15_Strings and  Dynamic Memory Allocation.pptx
Lecture 15_Strings and Dynamic Memory Allocation.pptx
 
C++ Programming Homework Help
C++ Programming Homework HelpC++ Programming Homework Help
C++ Programming Homework Help
 
Linked list
Linked listLinked list
Linked list
 
Savitch Ch 08
Savitch Ch 08Savitch Ch 08
Savitch Ch 08
 
C aptitude questions
C aptitude questionsC aptitude questions
C aptitude questions
 
C - aptitude3
C - aptitude3C - aptitude3
C - aptitude3
 
Unit 2
Unit 2Unit 2
Unit 2
 
Unitii string
Unitii stringUnitii string
Unitii string
 
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...
 
booksoncprogramminglanguage-anintroductiontobeginnersbyarunumrao4-21101016591...
booksoncprogramminglanguage-anintroductiontobeginnersbyarunumrao4-21101016591...booksoncprogramminglanguage-anintroductiontobeginnersbyarunumrao4-21101016591...
booksoncprogramminglanguage-anintroductiontobeginnersbyarunumrao4-21101016591...
 
Savitch ch 08
Savitch ch 08Savitch ch 08
Savitch ch 08
 
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
 
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
 
Functions torage class and array and strings-
Functions torage class and array and strings-Functions torage class and array and strings-
Functions torage class and array and strings-
 
Imugi: Compiler made with Python
Imugi: Compiler made with PythonImugi: Compiler made with Python
Imugi: Compiler made with Python
 
CPP Homework Help
CPP Homework HelpCPP Homework Help
CPP Homework Help
 
Diploma ii cfpc u-4 function, storage class and array and strings
Diploma ii  cfpc u-4 function, storage class and array and stringsDiploma ii  cfpc u-4 function, storage class and array and strings
Diploma ii cfpc u-4 function, storage class and array and strings
 
06 -working_with_strings
06  -working_with_strings06  -working_with_strings
06 -working_with_strings
 
Mcai pic u 4 function, storage class and array and strings
Mcai pic u 4 function, storage class and array and stringsMcai pic u 4 function, storage class and array and strings
Mcai pic u 4 function, storage class and array and strings
 
function, storage class and array and strings
 function, storage class and array and strings function, storage class and array and strings
function, storage class and array and strings
 

Recently uploaded

UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
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
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 

Recently uploaded (20)

UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
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
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 

String .h

  • 2. String.h- This header file defines several functions to manipulate C strings and arrays. Functions declared in string.h are extremely popular since as a part of the C standard library, they are guaranteed to work on any platform which supports C Some of its functions are defined below .
  • 3. Memcpy:- Use Copy block of memory   SYNOPSIS #include <string.h> void *memcpy(void *s1, const void *s2, size_tn);   DESCRIPTION The memcpy() function copies n bytes from the object pointed to by s2 into the object pointed to by s1. If copying takes place between objects that overlap, the behaviour is undefined.   RETURN VALUE The memcpy() function returns s1; no return value is reserved to indicate an error.
  • 4. Example /* memcpy example */ #include <stdio.h> #include <string.h>  int main () { char str1[]="Sample string"; char str2[40]; char str3[40]; memcpy (str2,str1,strlen(str1)+1); memcpy (str3,"copy successful",16); printf ("str1: %sstr2: %sstr3: %s",str1,str2,str3); return 0; } Output str1: Sample string str2: Sample string str3: copy successful
  • 5. memmove memmove Memmove:- Use Move block of memory SYNOPSIS #include <string.h> void *memmove(void *s1, const void *s2, size_tn);   DESCRIPTION The memmove() function copies n bytes from the object pointed to by s2 into the object pointed to by s1. Copying takes place as if the n bytes from the object pointed to by s2 are first copied into a temporary array of n bytes that does not overlap the objects pointed to by s1 and s2, and then the n bytes from the temporary array are copied into the object pointed to by s1.  RETURN VALUE The memmove() function returns s1; no return value is reserved to indicate an error.
  • 6. Example /* memmove example */ #include <stdio.h> #include <string.h> int main () { char str[] = "memmove can be veryuseful......"; memmove (str+20,str+15,11); puts (str); return 0; }} } Output memmove can be very very useful.
  • 7. Memcmp :- Use Compare two blocks of memory SYNOPSIS #include <string.h> intmemcmp(const void *s1, const void *s2, size_tn);   DESCRIPTION The memcmp() function compares the first n bytes of the object pointed to by s1 to the first nbytes of the object pointed to by s2. The sign of a non-zero return value is determined by the sign of the difference between the values of the first pair of bytes that differ in the objects being compared.   RETURN VALUE The memcmp() function returns an integer greater than, equal to or less than 0, if the object pointed to by s1 is greater than, equal to or less than the object pointed to by s2 respectively.
  • 8. Example /* memcmp example */ #include <stdio.h> #include <string.h>   int main () { char str1[256]; char str2[256]; int n; size_t len1, len2; printf ("Enter a sentence: "); gets(str1); printf ("Enter another sentence: "); gets(str2); len1=strlen(str1); len2=strlen(str2); n=memcmp ( str1, str2, len1>len2?len1:len2 ); if (n>0) printf ("'%s' is greater than '%s'.",str1,str2); else if (n<0) printf ("'%s' is less than '%s'.",str1,str2); else printf ("'%s' is the same as '%s'.",str1,str2); return 0; } Output Enter a sentence: building Enter another sentence: book 'building' is greater than 'book'
  • 9. Memset:- Use Fill block of memory SYNOPSIS #include <string.h> void *memset(void *s, intc, size_tn);  DESCRIPTION The memset() function copies c (converted to an unsigned char) into each of the first n bytes of the object pointed to by s.   RETURN VALUE The memset() function returns s; no return value is reserved to indicate an error.
  • 10. Example /* memset example */ #include <stdio.h> #include <string.h>   int main () { char str[] = "almost every programmer should know memset!"; memset (str,'-',6); puts (str); return 0; } Output ------ every programmer should know memset!
  • 11. Memchr Use Locate character in block of memory  SYNOPSIS #include <string.h> void *memchr(const void *s, intc, size_tn);  DESCRIPTION The memchr() function locates the first occurrence of c (converted to an unsigned char) in the initial n bytes (each interpreted as unsigned char) of the object pointed to by s.   RETURN VALUE The memchr() function returns a pointer to the located byte, or a null pointer if the byte does not occur in the object.
  • 12. Example /* memchr example */ #include <stdio.h> #include <string.h>   int main () { char * pch; char str[] = "Example string"; pch = (char*) memchr (str, 'p', strlen(str)); if (pch!=NULL) printf ("'p' found at position %d.", pch-str+1); else printf ("'p' not found."); return 0; } Output 'p' found at position 5.
  • 13. Thanks for watching .Hope u like it….. By :- NISHANK