small program to find biggest number

Hello i'm Denis, new to programming and i have a question which i'd be verry gratefull if you help me find answer to:

ok i'll try to explain as best as possible:

What shoud do: Program that one can enter a numbers (for example "56354290") and the idea is the program to bring out the biggest number.

So it shoud break the numbers in array and the loop (i guess) thru them to find the biggest one.

My idea: make an integer array, the user enters the numbers and it loops thru them (simple as that). The problem is that when i make that integer and i put it in the "cin>>theNumber" for example, it gives me error because i have to tell it to which array number shoud the numbers input.

So how can i first break an integer to an integer array?

Thanks :)
cin >> myArray[index] will work
BTW, should 56354290 be a single number or you want to store the various digits
well i was thinking of 2 ways

1: store the whole number in a integer and then somehow break it in array

2: store each digit in array..

second case was better off-course, but i coudn't find a solver to the error that it's giving me because i was typing something like that:

int inputNumber[100];
cin >> inputNumber;

and it gives me error because i am not telling it to which number in the stack to input the information. As far as i can understand the "[index]" means' to arrange them in a stack?

Thank you
The index is the offset of the array element you want to get.
For the second way: It's easier if you read the number as a string and then access its character. You'll need to convert from ASCII to actual value, for that you can subtract '0'
i'll see what i can do...

how can i convert a string to integer? Can i do that with whole array?

thanks
Subtract '0' from each character like Bazzy said. And, yes, you can do it on the whole array. Why wouldn't you be able to?
EDIT: didn't read properly
Last edited on
Because i'm learning C++ from 3, 4 days :D

Thanks guys for the help
Topic archived. No new replies allowed.