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)

PPTX
Sustainable Sites - Green Building Construction
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPTX
Geodesy 1.pptx...............................................
PPTX
Lecture Notes Electrical Wiring System Components
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PPTX
Internet of Things (IOT) - A guide to understanding
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
composite construction of structures.pdf
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
DOCX
573137875-Attendance-Management-System-original
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
Sustainable Sites - Green Building Construction
CYBER-CRIMES AND SECURITY A guide to understanding
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
Geodesy 1.pptx...............................................
Lecture Notes Electrical Wiring System Components
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
R24 SURVEYING LAB MANUAL for civil enggi
Internet of Things (IOT) - A guide to understanding
Model Code of Practice - Construction Work - 21102022 .pdf
Foundation to blockchain - A guide to Blockchain Tech
composite construction of structures.pdf
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
573137875-Attendance-Management-System-original
Automation-in-Manufacturing-Chapter-Introduction.pdf

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.