I'm supposed to write a function that takes an input, and then outputs a set number of digits based on an array. The code I have works for the numbers 1-10, but anything above that messes up because it goes on to a value that doesn't exist in the array. I'd like for the program to handle values up to 127.
The problem isn't limiting inputs, it's just I have no idea how to make it go above 10 without going wonky.
For example:
Input Output
0 0
9 0123456789
19 01234567890123456789
25 01234567890123456789012345
#include <iostream>
using namespace std;
int main(){
int input;
int num[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
cin >> input;
cout << endl;
int i;
for(i=0;i<input;i++){
cout << num[i];
}}