how to use the cin.getline() fn to write something ina string
String character array
@Priyanshu-Goel-1161416680732439 Hey Priyanshu,
cin.getline() is used to take input of character array not string.
cin.getline():
-> cin.getline( characterArrayName , arraySize , delimiter(optional) )
-> By default Delimiter = ‘\n’(new Line)
-> The function does the following operations:
1. Extracts character up to the delimiter.
2. Stores the characters in the buffer.
3. Maximum number of characters extracted is size-1.
> The terminator character is read but not saved into a buffer, instead it is replaced by the null character
for string you can use getline
e.g getline(cin , stringName , delimiter(optional));
Hello,
You have not replied to this thread for 13 days.
So, I am marking this doubt as resolved.
In case, you still have some doubts regarding the same problem, you can reopen this doubt.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.