I have commented a part in my code please check and explain.
Doubt in '\n' vs '\0'
What wrong with code??
Now to Rectify it : βwhat can we do???β
Modified Code:
one way:
(it will not evaluate \n)
cin.getline(arr,101,'\n');
ch=arr[0];
while(arr[i]!='\0') // taking \0 here, makes my code working.. please explain
{
other way:
(it will evaluate \n as well )
cin.getline(arr,101,'\0');
ch=arr[0];
while(arr[i]!='\0') // taking \0 here, makes my code working.. please explain
{
i hope this helps,
if you have further doubt feel free to ask
Such a wonderful explanation. That means at the end of character array or string compiler itself inserts β\0β?
yes,
bcz string is a character array terminated with β\0β
Thanks a lot. Wonderful explanation by you.
i am resolving your doubt,
plz give your valuable feedback
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.