Deleting a Single Value from a Vector in C++

https://youtu.be/Gzdenp3OZ48?si=ovpigthygEnZRU6w #include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { vector<int> v = {67, 3, 5, 7, 9, 1}; v.erase(v.begin() + 1); for (auto el : v)…

Lambda Expressions in C++

Lambda expressions are anonymous unnamed function objects. https://youtu.be/iUtyX8c1pIw #include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int i = 30; int x = 50; auto lambda…

Min and Max Elements in C++

https://youtu.be/hzus6dhSIhw?si=HyP0x6n6DUtVhUfJ #include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { vector<int> v = {6, 5, 9, 8, 50, 311, 22}; // auto it = max_element(begin(v), end(v)); auto…

std copy function in C++

https://youtu.be/Tyt060FRiS8?si=rKxV8SYqUsG56lhE #include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { vector<int> copy_from_vector = {5, 7, 8, 9, 0, 10}; vector<int> copy_to_vector(6); copy(copy_from_vector.begin(), copy_from_vector.begin() + 3, copy_to_vector.begin()); for…

std sort function in C++

https://youtu.be/nq_8aNhxfTs #include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { vector<int> v1 = {1, 6, 2, 5, 10, 4, 11, 3}; sort(v1.begin(), v1.end(), greater<int>()); for (auto el…

std map in C++

https://youtu.be/79s8gkLF6Y8 #include <iostream> #include <map> using namespace std; int main() { map<int, char> m = {{1, 'A'}, {2, 'B'}, {3, 'C'}}; for (auto el : m) { cout << el.first…

std::vector in C++

#include <iostream> #include <vector> using namespace std; int main() { vector<int> v = {4, 5, 6}; v.push_back(7); cout << v[0] << endl; cout << v[3] << endl; cout << "The…

String Streams in C++

https://youtu.be/6WIevcEVBqY?si=xM945G9koO3GoEe3 #include <iostream> #include <sstream> #include <string> using namespace std; int main() { stringstream sStream{"Hello World!"}; cout << sStream.str() << endl; stringstream ss; ss << "Hi There"; cout << ss.str()…

File Streams in C++ read from a file and Write to a file

https://youtu.be/WiZW58Hzt9A?si=BMVrM0xJLcX-k-Sm #include <iostream> #include <fstream> #include <string> using namespace std; int main() { fstream fStream{"read.txt"}; string line; while (fStream) { getline(fStream, line); cout << line << endl; } fstream f{"read.txt"};…