Extracting and comparing numbers

Hey everyone, I'm new to C++ and know how to extract numbers (for example, to extract 1 from 1289371 I need to do modulo 10 [% 10] and I can do it in a while loop with dividing to keep using modulo on the numbers after) but I don't know how to extract a number and then extract the one after and compare to see which one is larger and then do the same thing again and find out which one is smaller and print them both out.

i.e. Input : 783214

prints out: largest number is 8

smallest number is 1

Can anyone help me?

Thanks.

My code so far:

Code:

int largeNum;

int smallNum;

int current1;

int current2;

while (num != 0){

current1 = num % 10;

num /= 10;

current2 = num % 10;

if( current1 > current2 ){

largeNum == current1;

}

if( current1 < current2 ){

largeNum == current2;

}

}

cout << "The largest digit : " << largeNum << endl;

cout << "The smallest digit : " << smallNum << endl;