c++ - How to find the position of a digit and use them -
#include <iostream> #include <math.h> #include <string> #include <sstream> using namespace std; int main() { string input; int value, cout << "input number: " << endl; cin >> input; const int count = input.length(); istringstream buffer(input); buffer >> value; if (count == 4) {
my program suppose count length of number, if it's 4 encode digits. eg. 1234 turns other digits. question how take each individual digit , use them. eg. take (1+1)/10, or (3+2)/10.
you can character in string using bracket notation, e.g input[0]
first character in string.
Comments
Post a Comment