Hello programmers,
I know that string input can be used as a char array in c++
I was wondering if this is possible with int input to int array as well
for exammple, when the input is 101011, can it be converted to an array whose each element holds one digit like
1 2
array[]= '101011'; //this to
array[7] = {1,0,1,0,1,1}; //this
or do I have to make it as a char array and convert each element to an integer??
strings are kind of a special case, you can't do this.
you can read ints as ints...
int x;
cin >> x;
or as strings and convert it.
and each is its own, you can't read directly "as an array" you have to read each one into the array elements.
strings, each array element is read one by one same way, but the string and reading functions know how to handle the array locations for you.