Here, we are going to learn about, what are C-Style Strings and what is String class . So, let's start by giving you the introduction. C-Style String is nothing but, an array of characters, and from the term array we can surely assume that these are static in size i.e. the size of these C-Style strings cannot be increased or decreased. String Class is a Built-in class that provide us much more functionality than C-Style String. C-STYLE STRINGS Before learning the String class, which is full-fledged feature of C++, we should rather start by taking a look at some important things about C-Style String. C-Style Strings are actually array of characters that are terminated by a null character "\0". If you are confused with, why null character? The reason is that, It helps us to define, upto which index we have some useful data present in our character array, and after null character there may or may not be some garbage values of characters. Let's first start by showing a
I have already introduced pointers in the C++ Derived Data Types post , But, here I will be showing some practical examples and at the end of this slide, you will be understanding pointers like they are, obvious to you. So, let' start by reminding you the basic syntax :- <data type> *<name_of_pointer> ; Below is the simple program for pointer declaration and initialization. #include<iostream> using namespace std; int main (){ int a = 20 ; int *b; // Declaration of pointer b b = &a; // Initialization of pointer b (& is used to extract the address of a) int *c = b; // Initialization of pointer c to pointer b cout << a << endl << b << endl << c << endl; } Okay, after reminding the basic syntax of pointers, you have to memorize the reason why we generally use pointers, I have already discussed that also, but, let me briefly describe it. One of the memory section in our Comp