If in a string at some index there is a number and I want to store it another variable then why we do int n=str[i]-'0' in c++?

后端 未结 0 1752
挽巷
挽巷 2020-11-22 01:48

I tried without \'0\' and got error,Please explain it.

getline(cin,str);
int n=str[4]-\'0\';
相关标签:
回答
  • 消灭零回复
提交回复
热议问题