SlideShare a Scribd company logo
String (Computer programming and utilization)
 A string is a sequence of character that is treated
as a single data item.
 String is represented as a CHARACTER ARRAY.
Declaration of string
 Syntax:- char string_name[length];
 Example:- char name[5];
 This example declares an array name
which can store at the most 5
characters.
 Character array can be initialiized in two ways- as
individual character or as single string.
 Example:-
Char greet[10]= {‘h’, ’e, ’l’, ‘l’, ‘o’, ‘!’};
Char greet[10]=“hello!”;
Char greet[]=“hello!”;
 The compiler automatically stores the null
character at the end of the string. Memory
representation of char greet[]=“hello!”; is as
follows:
h e l l o ! 0
 We are familiar with two standard function for
reading input and writing output – scanf() and
printf() respectively.
 These functions with format specifiers %c and
%s can be used for input and output of
characters and strings.
 The example given in the next slide.
 Ex:- char color {6};
 Scanf(“%c”, & color); // reading char
 Scanf(“%s”, & color); // reading string
 printf(“%c”, & color); // writing char
 printf(“%s”, & color); // writing string
 WE have seen other I/o functions for
character and string –
getchar,putchar,gets,puts in the chapter 2.
 Strlen(s1):- Return the length of the string s1
excluding the null character.
 Strlwr(s1):- Convert the string s1 to lower
case.
 Strcat(s1,s2):- Appends a copy of string s2 to
end of s1 and terminates s1 with a null and a
return s1.
 Strcmp(s1,s2):- Compress s1 and s2 and
returns –ve if s1<s2 , +ve if s1>s2 , 0 if
s1=s2.
 Strcpy(s1,s2):- copies the string s2 into
s1,modifying the string s1.
 Strcmpi(s1,s2):- Compress s1 and s2
ignoring the case and return similar result as
strcmp.
 Strncmp(s1,s2,n):- compress the first n
character of string s1 and s2 and return
similar result as strcmp.
 Strupr(s1):- Convert the string s1 to
uppercase.
 Strchr(s1,c):- Returns a pointer to the first
occurrence of the character c in string s1.
 Strrchr(s1,c):- Returns a pointer to the last
occurrence of the character c in string s1.
 Strstr(s1,s2):- Returns a pointer to the first
occurrence of the string s2 in string s1.
 Strrev(s1):- Returns the reverse string of
string s1.
 Strtok(s1,s2):- Searches s1 for tokens that
are separated by delimiters specified in s2.
Returns the pointer to first char to first token
in s1.
 Steset(s1,c):- Sets all characters in string s1
to character c and quites when null character
is detected.
 Strnset(s1,c,n):- Sets the first char in string
s1 to char c and quits when nill char is
detected.
 Sscanf:- Divided lines into tokens.
String (Computer programming and utilization)

More Related Content

PPT
Matrix and its operation (addition, subtraction, multiplication)
PPTX
Matrices
PPT
String & its application
PPTX
Strings CPU GTU
PPTX
String in programming language in c or c++
PPTX
Week6_P_String.pptx
PPSX
Strings
PPT
Lesson in Strings for C Programming Lessons
Matrix and its operation (addition, subtraction, multiplication)
Matrices
String & its application
Strings CPU GTU
String in programming language in c or c++
Week6_P_String.pptx
Strings
Lesson in Strings for C Programming Lessons

Similar to String (Computer programming and utilization) (20)

PPT
string function with example...................
PPT
Strings
PDF
5 2. string processing
PPTX
string manipulation in python ppt for grade 11 cbse
DOCX
C Programming Strings.docx
PDF
[ITP - Lecture 17] Strings in C/C++
PPTX
Strings and pointers
PPTX
cprogramming strings.pptx
PPTX
cprogramming strings.pptx
PPTX
PPT
PPT
Unit-3 Strings.pptreeeeeeeeeeeeeereeeeere
PPT
PPT
Cfbcgdhfghdfhghggfhghghgfhgfhgfhhapter11.PPT
PPTX
Handling of character strings C programming
PPTX
introduction to strings in c programming
PPT
Chapterabcdefghijklmnopqrdstuvwxydanniipo
PDF
python1uhaibueuhERADGAIUSAERUGHw9uSS.pdf
string function with example...................
Strings
5 2. string processing
string manipulation in python ppt for grade 11 cbse
C Programming Strings.docx
[ITP - Lecture 17] Strings in C/C++
Strings and pointers
cprogramming strings.pptx
cprogramming strings.pptx
Unit-3 Strings.pptreeeeeeeeeeeeeereeeeere
Cfbcgdhfghdfhghggfhghghgfhgfhgfhhapter11.PPT
Handling of character strings C programming
introduction to strings in c programming
Chapterabcdefghijklmnopqrdstuvwxydanniipo
python1uhaibueuhERADGAIUSAERUGHw9uSS.pdf
Ad

More from Digvijaysinh Gohil (20)

PPTX
Hydraulic cranes
PPTX
Hydraulic braking systems
PPTX
Human resources management
PPTX
Traits of a good listner (Communication Skills)
PPT
Techniques of reading (Communication Skills)
PPTX
Proxemics (Communication Skills)
PPTX
Proxemics (2) (Communication Skills)
PPTX
Paralinguistic (Communication Skills)
PPTX
Paralinguistic (2) (Communication Skills)
PPTX
Paralinguistic (1) (Communication Skills)
PPTX
Organizing a contents &amp; preparing an outline
PPTX
Organizing a contents &amp; preparing an outline (2)
PPTX
Kinesics (Communication Skills)
PPTX
Kinesics (3) (Communication Skills)
PPTX
Kinesics (2) (Communication Skills)
PPTX
Introduction to communication (Communication Skills)
PPTX
Email etiquette (Communication Skills)
PPTX
Welded joints (machine design & industrial drafting )
PPTX
Types of stresses and theories of failure (machine design & industrial drafti...
PPTX
Treaded joint (machine design & industrial drafting )
Hydraulic cranes
Hydraulic braking systems
Human resources management
Traits of a good listner (Communication Skills)
Techniques of reading (Communication Skills)
Proxemics (Communication Skills)
Proxemics (2) (Communication Skills)
Paralinguistic (Communication Skills)
Paralinguistic (2) (Communication Skills)
Paralinguistic (1) (Communication Skills)
Organizing a contents &amp; preparing an outline
Organizing a contents &amp; preparing an outline (2)
Kinesics (Communication Skills)
Kinesics (3) (Communication Skills)
Kinesics (2) (Communication Skills)
Introduction to communication (Communication Skills)
Email etiquette (Communication Skills)
Welded joints (machine design & industrial drafting )
Types of stresses and theories of failure (machine design & industrial drafti...
Treaded joint (machine design & industrial drafting )
Ad

Recently uploaded (20)

PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
DOCX
573137875-Attendance-Management-System-original
PDF
Digital Logic Computer Design lecture notes
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
Welding lecture in detail for understanding
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPTX
OOP with Java - Java Introduction (Basics)
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PPTX
Lecture Notes Electrical Wiring System Components
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
web development for engineering and engineering
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
573137875-Attendance-Management-System-original
Digital Logic Computer Design lecture notes
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Welding lecture in detail for understanding
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Automation-in-Manufacturing-Chapter-Introduction.pdf
OOP with Java - Java Introduction (Basics)
R24 SURVEYING LAB MANUAL for civil enggi
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Lecture Notes Electrical Wiring System Components
CH1 Production IntroductoryConcepts.pptx
Internet of Things (IOT) - A guide to understanding
UNIT-1 - COAL BASED THERMAL POWER PLANTS
Embodied AI: Ushering in the Next Era of Intelligent Systems
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
web development for engineering and engineering

String (Computer programming and utilization)

  • 2.  A string is a sequence of character that is treated as a single data item.  String is represented as a CHARACTER ARRAY. Declaration of string  Syntax:- char string_name[length];  Example:- char name[5];  This example declares an array name which can store at the most 5 characters.
  • 3.  Character array can be initialiized in two ways- as individual character or as single string.  Example:- Char greet[10]= {‘h’, ’e, ’l’, ‘l’, ‘o’, ‘!’}; Char greet[10]=“hello!”; Char greet[]=“hello!”;  The compiler automatically stores the null character at the end of the string. Memory representation of char greet[]=“hello!”; is as follows: h e l l o ! 0
  • 4.  We are familiar with two standard function for reading input and writing output – scanf() and printf() respectively.  These functions with format specifiers %c and %s can be used for input and output of characters and strings.  The example given in the next slide.
  • 5.  Ex:- char color {6};  Scanf(“%c”, & color); // reading char  Scanf(“%s”, & color); // reading string  printf(“%c”, & color); // writing char  printf(“%s”, & color); // writing string  WE have seen other I/o functions for character and string – getchar,putchar,gets,puts in the chapter 2.
  • 6.  Strlen(s1):- Return the length of the string s1 excluding the null character.  Strlwr(s1):- Convert the string s1 to lower case.  Strcat(s1,s2):- Appends a copy of string s2 to end of s1 and terminates s1 with a null and a return s1.  Strcmp(s1,s2):- Compress s1 and s2 and returns –ve if s1<s2 , +ve if s1>s2 , 0 if s1=s2.
  • 7.  Strcpy(s1,s2):- copies the string s2 into s1,modifying the string s1.  Strcmpi(s1,s2):- Compress s1 and s2 ignoring the case and return similar result as strcmp.  Strncmp(s1,s2,n):- compress the first n character of string s1 and s2 and return similar result as strcmp.  Strupr(s1):- Convert the string s1 to uppercase.
  • 8.  Strchr(s1,c):- Returns a pointer to the first occurrence of the character c in string s1.  Strrchr(s1,c):- Returns a pointer to the last occurrence of the character c in string s1.  Strstr(s1,s2):- Returns a pointer to the first occurrence of the string s2 in string s1.  Strrev(s1):- Returns the reverse string of string s1.
  • 9.  Strtok(s1,s2):- Searches s1 for tokens that are separated by delimiters specified in s2. Returns the pointer to first char to first token in s1.  Steset(s1,c):- Sets all characters in string s1 to character c and quites when null character is detected.  Strnset(s1,c,n):- Sets the first char in string s1 to char c and quits when nill char is detected.  Sscanf:- Divided lines into tokens.