8.2 - CStrings - OOP Assignment 3
8.2 - CStrings - OOP Assignment 3
8.2 - CStrings - OOP Assignment 3
Important Instructions:
1- Subscript operator and integer iterators are ALLOWED, do not use offset notations and
pointers iterators.
2- Pass all the pointers by value unless you explicitly need a pointer to be changed in callee.
3- Make sure that you DO NOT consume any single extra byte.
Write a function that takes two strings inputs and appends str2 at the end of str1. Don not
change the return type Void. For example,
String 1: “Happy Birthday” (Input String 1 doesn’t have any extra space)
String 2: “ to you !”
After StringConcatenate,
2. Char** StringTokens(char*)
Write a function which takes a string and returns an array of words in the string. For example:
3. Char** InverseStringTokens(char*)
Write a function which takes a string and returns its words in reverse order. Use previous
function to accomplish this task. For example:
String: I am a student of OOP in FAST-NU
Function returns Tokens in reverse order:
FAST-NU
in
OOP
of
student
a
am
I
Note: Do not consume space of single extra character. Printing is not part of this function.
4. Char* ReverseSentence(char*)
Write a function that takes a sentence and returns its inverse, use previous functions to accomplish this
task to get credit. For example
String: “I am Pakistani”
String: “Pakistani am I” (Return new string. Do not change the original string. Printing is not part of this
function.)
Take any two strings, sort them alphabetically (ignore casing), this is how your function should compare
the strings.
Important Note:
Create a main program and then test all of these functions. You must dynamically allocate and
deallocate memory to all the strings in your program (except the temporary buffer). There should not be
any memory leakages and dangling pointers in your program.
Sample Run:
Testing StringConcatenate:
String 1: “I am a student”
String 2: “ of OOP in FAST-NU”
After Concatenation:
String 1: “I am a student of CP in FAST-NU”
String 2: “of OOP in FAST-NU”
------------------------------------------------------------------------------------------------------------
Testing StringTokens:
I
am
a
student
of
CP
In
FAST-NU
------------------------------------------------------------------------------------------------------------
Testing InverseStringTokens:
FAST-NU
in
CP
of
student
a
am
I
------------------------------------------------------------------------------------------------------------
Testing ReverseSentence
//String 2
of OOP in FAST-NU
82 // TotalStudents
Yasoob Tahavi
Abdul moeez
Muhammmad Suhaib
Jarar Asif
Waleed Ikram
Suhaib Ahmad
Isbah Malik
Hassaan Mustafavi
Abdul Moiz
Moazzam Anwaar
Areeba Shahzadi
Maryam Saqib
Zaid Asif
Rida Amir
Ubaid Ur
Umer Habib
Abdur Rehman
Ghulam Mohyudin
Anzar Zahid
Haris Umer
Fajar Ejaz
Awab Mujtaba
Muhammad Ahmad
Hassan Ali
Hamza Amer
Ameer Humza
Abdul Tawab
Hina Fatima
Zafeer Tariq
Aatika Abid
Abdullah Zia
Haisem Naeem
Minahil Tariq
Muzammil Rasool
Maarib Ahmed
Talha Mohy
Muhammad Anas
Subayyal Saeed
Shahryar Ahmad
Abdul Arham
Obaid Ullah
Saad Parvez
Zakriya Tariq
Saad Chaudhry
Faran Ahmad
Mehdy Hasnain
Arham Shahzad
Raabia Baig
Umair Asim
Muhammad Zamin
Ahmad Aziz
Muhammad Mujtaba
Khadeeja Wasif
Saad Hussain
Rafia Karim
Farhan Bukhari
Hassan Jaffar
Asad Tariq
Halima Sadia
Abdullah Basim
Muhammad Tayyab
Muhammad Owais
Rabiya Irfan
Laiba Mubbashir
Muhammad Faizan
Ariba Arshad
Abdullah Suhail
Duaa Sohail
Muhammad Ahmad
Mahdiah Aqib
Hadi Ali
Hamza Ali
Rafeel Abdul
Mahad Hassan
Nabiha Tariq
Ahmad Sadeed
Mustaqim Afzal
Rafay Junaid
Hamza Mansoor
Abdul Rahim
Hassan Zubair
Abdul Hadi