You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
char h = 'h'; // takes only single aplhabetical character in single (') quotes
cout << h << endl;
string i = "hello how";
cout << i << endl;
// NOTE:
// in this these two char and string are mainly used but there is other one that is getline, it has a different use case here is an example, so consider that:
string j;
cout << "Enter sentence for j: ";
cin >> j;
cout << j << endl;
/* OUTPUT:
hello how
Enter sentence for j: hello how are you
hello[Finished in 6.5s] */
// as you saw we wrote a 4 word sentence still we get only the first word printed, to solve this problem we have getline
string k;
cout << "Enter the sentence for k: ";
getline(cin, k);
cout << k << endl;
// getline takes the input and stores it in the vaiable and also print the output
// REMENDER: if you are running line 49 to 52 make sure line all the above code is commented out otherwise it will not work in some cases: