x = 1000*number[0] + 100*number[1] + 10*number[2] + number[3];
This is basically how decimal numbers work. A more general version (when you do not know how long the "number") will be:
int x = 0; int base = 10; for(int ii = 0; ii < sizeof(number); ii++) x = base*x + number[ii];
Note. If base is something other than 10, the above code will work. Of course, if you typed x using the usual cout<<x , you get a confused answer. But it may serve you another time. Of course, you really want to check that number[ii] is between 0 and 9 inclusive, but this is pretty much implied by your question. However, good programming requires verification, verification, and verification. I am sure you can add this bit yourself.
source share