SlideShare a Scribd company logo
2
Most read
3
Most read
5
Most read
Character Array (Strings)
Prepared By: Mr. Sangram A. Patil
Assistant Professor PVPIT,Budhgaon
Definition : String
 Strings are actually one-dimensional array of characters terminated by
a null character '0'.
 Declaration and initialization of string
char str[6]={‘H,’e’,’l’,’l’,’o’,’0’};
Or
char str[6]=“Hello”;
 Actually, you do not place the null character at the end of a string constant. The C
compiler automatically places the '0' at the end of the string when it initializes the
array.
#include <stdio.h>
int main () {
char message[6] = {'H', 'e', 'l', 'l', 'o', '0'};
printf(“Message: %sn", message );
return 0;
}
• It is also possible to access character array by using for
loop.
• Also we can get whole string at a time and print it using
%s format specifier.
String related functions
Sr.No. Function & Purpose
1 strcpy(s1, s2);
Copies string s2 into string s1.
2 strcat(s1, s2);
Concatenates string s2 onto the end of string s1.
3 strlen(s1);
Returns the length of string s1.
4 strcmp(s1, s2);
Returns 0 if s1 and s2 are the same; less than 0 if s1<s2; greater than 0 if
s1>s2.
strchr(s1, ch);
Returns a pointer to the first occurrence of character ch in string s1.
6 strstr(s1, s2);
Returns a pointer to the first occurrence of string s2 in string s1.
Character array (strings)

More Related Content

What's hot (20)

PDF
String.ppt
ajeela mushtaq
 
PDF
Strinng Classes in c++
Vikash Dhal
 
PPT
Lecture 6
Mohammed Saleh
 
PPTX
Strings in C
Kamal Acharya
 
PPSX
Strings
Dhiviya Rose
 
PPT
Strings
Mitali Chugh
 
PPTX
Strings in programming tutorial.
Samsil Arefin
 
PPTX
String Handling in c++
Fahim Adil
 
PPTX
C programming - String
Achyut Devkota
 
PDF
Strings
Michael Gordon
 
PPT
Strings
Nilesh Dalvi
 
PPT
Strings
Imad Ali
 
PPTX
Strings in C language
P M Patil
 
PPTX
C++ string
Dheenadayalan18
 
PDF
05 c++-strings
Kelly Swanson
 
PPT
Operation on string presentation
Aliul Kadir Akib
 
PPTX
C string
University of Potsdam
 
PPTX
The string class
Syed Zaid Irshad
 
PPTX
Handling of character strings C programming
Appili Vamsi Krishna
 
String.ppt
ajeela mushtaq
 
Strinng Classes in c++
Vikash Dhal
 
Lecture 6
Mohammed Saleh
 
Strings in C
Kamal Acharya
 
Strings
Dhiviya Rose
 
Strings
Mitali Chugh
 
Strings in programming tutorial.
Samsil Arefin
 
String Handling in c++
Fahim Adil
 
C programming - String
Achyut Devkota
 
Strings
Nilesh Dalvi
 
Strings
Imad Ali
 
Strings in C language
P M Patil
 
C++ string
Dheenadayalan18
 
05 c++-strings
Kelly Swanson
 
Operation on string presentation
Aliul Kadir Akib
 
The string class
Syed Zaid Irshad
 
Handling of character strings C programming
Appili Vamsi Krishna
 

Similar to Character array (strings) (20)

PDF
Strings in c language
Infinity Tech Solutions
 
PDF
[ITP - Lecture 17] Strings in C/C++
Muhammad Hammad Waseem
 
PPT
Lecture 17 - Strings
Md. Imran Hossain Showrov
 
PPT
CPSTRINGSARGAVISTRINGS.PPT
Sasideepa
 
PPT
BHARGAVISTRINGS.PPT
Sasideepa
 
PPTX
fundamentals of c programming_String.pptx
JStalinAsstProfessor
 
PPTX
C - String ppt
Md Razib
 
PPT
Lec 16. Strings
Rushdi Shams
 
PPT
CP-STRING (1).ppt
mounikanarra3
 
PPT
CP-STRING.ppt
TAPANDDRAW
 
PPT
CP-STRING.ppt
arunatluri
 
PPT
string.ppt
lakshmanarao027MVGRC
 
PPT
Computer Programming- Lecture 5
Dr. Md. Shohel Sayeed
 
PPT
Unit-3 Strings.pptreeeeeeeeeeeeeereeeeere
edukuldeep2005
 
PPT
Strings
mandeepcse
 
PPT
Strings
reet_kaur001
 
PPT
Strings
reet_kaur001
 
DOCX
C Programming Strings.docx
8759000398
 
PPTX
strings in c language and its importance
sirmanohar
 
PPTX
String.pptx
Ananthi Palanisamy
 
Strings in c language
Infinity Tech Solutions
 
[ITP - Lecture 17] Strings in C/C++
Muhammad Hammad Waseem
 
Lecture 17 - Strings
Md. Imran Hossain Showrov
 
CPSTRINGSARGAVISTRINGS.PPT
Sasideepa
 
BHARGAVISTRINGS.PPT
Sasideepa
 
fundamentals of c programming_String.pptx
JStalinAsstProfessor
 
C - String ppt
Md Razib
 
Lec 16. Strings
Rushdi Shams
 
CP-STRING (1).ppt
mounikanarra3
 
CP-STRING.ppt
TAPANDDRAW
 
CP-STRING.ppt
arunatluri
 
Computer Programming- Lecture 5
Dr. Md. Shohel Sayeed
 
Unit-3 Strings.pptreeeeeeeeeeeeeereeeeere
edukuldeep2005
 
Strings
mandeepcse
 
Strings
reet_kaur001
 
Strings
reet_kaur001
 
C Programming Strings.docx
8759000398
 
strings in c language and its importance
sirmanohar
 
String.pptx
Ananthi Palanisamy
 
Ad

More from sangrampatil81 (20)

PPTX
Deadlock
sangrampatil81
 
PPTX
Memory Management
sangrampatil81
 
PPTX
virtual memory
sangrampatil81
 
PPTX
IO hardware
sangrampatil81
 
PPTX
File system structure
sangrampatil81
 
PPTX
File management
sangrampatil81
 
PPTX
Disk structure
sangrampatil81
 
PPTX
Directory structure
sangrampatil81
 
PPTX
Directory implementation and allocation methods
sangrampatil81
 
PPTX
Page replacement algorithms
sangrampatil81
 
PPTX
Methods for handling deadlock
sangrampatil81
 
PPTX
Semaphore
sangrampatil81
 
PPTX
Monitors
sangrampatil81
 
PPTX
Classical problems of process synchronization
sangrampatil81
 
PPTX
System programs
sangrampatil81
 
PPTX
System programs
sangrampatil81
 
PPTX
Services and system calls
sangrampatil81
 
PPTX
Operating system structure
sangrampatil81
 
PPTX
Operating system deign and implementation
sangrampatil81
 
PPTX
Pointer to array and structure
sangrampatil81
 
Deadlock
sangrampatil81
 
Memory Management
sangrampatil81
 
virtual memory
sangrampatil81
 
IO hardware
sangrampatil81
 
File system structure
sangrampatil81
 
File management
sangrampatil81
 
Disk structure
sangrampatil81
 
Directory structure
sangrampatil81
 
Directory implementation and allocation methods
sangrampatil81
 
Page replacement algorithms
sangrampatil81
 
Methods for handling deadlock
sangrampatil81
 
Semaphore
sangrampatil81
 
Monitors
sangrampatil81
 
Classical problems of process synchronization
sangrampatil81
 
System programs
sangrampatil81
 
System programs
sangrampatil81
 
Services and system calls
sangrampatil81
 
Operating system structure
sangrampatil81
 
Operating system deign and implementation
sangrampatil81
 
Pointer to array and structure
sangrampatil81
 
Ad

Recently uploaded (20)

PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PDF
Simplify React app login with asgardeo-sdk
vaibhav289687
 
PPTX
Get Started with Maestro: Agent, Robot, and Human in Action – Session 5 of 5
klpathrudu
 
PDF
NEW-Viral>Wondershare Filmora 14.5.18.12900 Crack Free
sherryg1122g
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PPTX
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PPTX
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PDF
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
PDF
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
PDF
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
PDF
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
Simplify React app login with asgardeo-sdk
vaibhav289687
 
Get Started with Maestro: Agent, Robot, and Human in Action – Session 5 of 5
klpathrudu
 
NEW-Viral>Wondershare Filmora 14.5.18.12900 Crack Free
sherryg1122g
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 

Character array (strings)

  • 1. Character Array (Strings) Prepared By: Mr. Sangram A. Patil Assistant Professor PVPIT,Budhgaon
  • 2. Definition : String  Strings are actually one-dimensional array of characters terminated by a null character '0'.  Declaration and initialization of string char str[6]={‘H,’e’,’l’,’l’,’o’,’0’}; Or char str[6]=“Hello”;
  • 3.  Actually, you do not place the null character at the end of a string constant. The C compiler automatically places the '0' at the end of the string when it initializes the array. #include <stdio.h> int main () { char message[6] = {'H', 'e', 'l', 'l', 'o', '0'}; printf(“Message: %sn", message ); return 0; } • It is also possible to access character array by using for loop. • Also we can get whole string at a time and print it using %s format specifier.
  • 4. String related functions Sr.No. Function & Purpose 1 strcpy(s1, s2); Copies string s2 into string s1. 2 strcat(s1, s2); Concatenates string s2 onto the end of string s1. 3 strlen(s1); Returns the length of string s1. 4 strcmp(s1, s2); Returns 0 if s1 and s2 are the same; less than 0 if s1<s2; greater than 0 if s1>s2. strchr(s1, ch); Returns a pointer to the first occurrence of character ch in string s1. 6 strstr(s1, s2); Returns a pointer to the first occurrence of string s2 in string s1.