Skip to Main Content
Fundamentals of Computer Programming and IT by Pearson
book

Fundamentals of Computer Programming and IT by Pearson

by Ashok Namdev Kamthane, Rohit Khurana
May 2024
Intermediate to advanced content levelIntermediate to advanced
577 pages
22h 34m
English
Pearson India
Content preview from Fundamentals of Computer Programming and IT by Pearson
Strings 379
14.7 PASSING STRINGS TO A FUNCTION
It is possible to access particular word or single character of string with the help of member functions of string
class. The supporting functions are illustrated with suitable examples.
at()
This function is used to access individual character. It requires one argument that indicates the ele ment
number. It is used in the given format.
s1.at(5);
Here s1 is a string object and 5 indicates 5th element that is to be accessed.
using namespace std;
int main()
{
string s1;
cout <<“\n Empty : “<<(s1.empty ()? “True” :”False”);
s1=”abc”;
cout <<“\n Empty: “<<(s1.empty() ? “True” :”False”);
return 0;
}
OUTPUT
Empty ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Basic Computer Engineering (Subject Code: BE - 205)  by Pearson

Basic Computer Engineering (Subject Code: BE - 205) by Pearson

Anita Goel, Anand Motwani

Publisher Resources

ISBN: 9781299447479