Printing Integers converted into string

I need to understand some basic C++ for a school assignment. I am a 12th grade programmer going to uni next year for CS and my main language right now is Java.

This program is meant to take in 3 numbers, if the numbers are in descending order, they should be printed, however when i print numbers such as 3,2,1 the numbers 0,124,0 are printed instead. How can i fix this?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
  #include <iostream>

using namespace std;

int main(){
    int variable1;
    int variable2;
    int variable3;
    
    string str1 = to_string(variable1);
    string str2 = to_string(variable2);
    string str3 = to_string(variable3);
    
    
    cout << "Enter A Number: ";
    cin >> variable1;
    cout << "Enter A Number: ";
    cin >> variable2;
    cout << "Enter A Number: ";
    cin >> variable3;
    if(variable1 > variable2 && variable2 > variable3){
	cout<< str1 << "," << str2<< ","  << str3 << endl;
	cout << str1 << endl;
	cout << str2 << endl;
	cout << str3 << endl;
    }
    else{
	cout<< "Numbers in Incorrect Order";
    }


    return 0;
    
}
1
2
3
    string str1 = to_string(variable1);
    string str2 = to_string(variable2);
    string str3 = to_string(variable3);

C++ doesn't revise the past based on new information, like doing cin >> variable1;

You input, then convert.
Thank You!
Topic archived. No new replies allowed.