So I saw this piece of code and I had the following queries ...
1] What does the string keyword do ? Is it like another data type to store strings ?
2] When is using the getline() more advantageous and when is using cin and storing the string in an array advantageous ? Even if you merely mention examples it'd help a lot
And for question 1, I did check information in the reference section , but I could't understand....
string is not a keyword, it's a class defined in the standard library. A managed dynamic string. The great thing about C++'s managed strings is that they can use characters of any size (8 bits, 16 bits, 32 bits, etc.). Not all languages have this feature.
Using getline() with a string lets you input lines of any length, so you don't have to worry about buffer overflows. getline() also defeats the space problem with std::cin (e.g. if you do std::cin >>Cstring; and input "Hello, World!", Cstring will only contain "Hello,").