fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. string s = "12";
  6. int digit = s[0] - '0'; // conversie din caracter în cifră
  7.  
  8. cout << digit << endl; // va afișa 1
  9. return 0;
  10. }
  11.  
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
1