C++ Lab 9 Alpha
C++ Lab 9 Alpha
C++ Strings
This lab has been designed to practice programs of C++ strings. In this lab students will
practice declaring, initializing and using C-string as well as string objects. Students will also
use getline() function to take string input. Clear concept about C++ strings has already been
provided in the class along with examples.
Objectives:
In this lab, you will practice:
C-string declaration and initialization.
Using getline() with C-string.
Using C-string predefined functions to perform string manipulation.
Class string object declaration and initialization.
Using getline() with string class.
Using string class functions for string manipulation.
Defining string array.
Defining 2D char array.
Question # 4: 2/
Write a program to count the total number of alphabets, digits and special characters in
a string.
Question # 5: 3/
Write a program to determine whether two strings are anagrams of each other. Anagram
means containing same letters in a different order e.g., rescue and secure are anagrams
of each other.
LAB MANUAL # 9
Course: Computer Programming (CP-107)
Session: 22CP Alpha
Question # 6: 4/
Write a program to explore and apply the following string library functions:
c-string functions:
Strlen, strcat, strcpy, strncat, strncpy, strcmp, strstr, atoi,
itoa
String class member functions:
compare, copy, length, append, at, insert, replace, swap, size.
****************