Lec 05 Strings
Lec 05 Strings
Lecture 5: Strings
khari.armih@gmail.com
or
4 int main()
5 {
6 char name[30];
7 cout << "What is your name: ";
8 cin >> name;
9 cout << "Hi, " << name;
10 return 0;
11 }
1 #include <iostream>
2 #include<string>
3 using namespace std;
4 int main()
5 {
6 string str1 ="I am studying computer language.";
7 string str2;
8 str2 = str1 + " What about you?";
9 cout << "str2: " << str2 << endl;
10 return 0;
11 }
15 return 0;
16 }
Dr. Khari Armih (khari.armih@gmail.com) Computer Language II June 16, 2023 21 / 22
lab 5
• Write an efficient functions to implement strcat and strcmp
functions in C++
• Write C++ function that swap two strings
• Write C++ program to find the number of words in a given
sentence