infininte loop

in is code I have an infinite loop but im not sure if removing it will hurt the switch statement that I have in main...will it?

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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
int main()  

{  

        int value;  

        do {  

               do {  

                      cout <<"Would you like to convert the weight or length:\n" 
                               "Press 1 for Lengths\n" 

                               "Press 2 for Weight or\n" 

                               "Press 0 to terminate program\n"; 

                      cin >> value;  

                      if (value != 0 && value != 1 && value != 2)  

                            cout << "Invalid entry." << endl;  

                      } while (value != 0 && value != 1 && value != 2);   

               switch (value)  

               {  

                      case 0:   

                            break;  

                      case 1: convert_lengths();   

                            break;  

                      case 2: convert_weights();  

                            break;  

               }   

        } while(value != 0);  

    

        return 0;  

 }  
Do you intend to reduce it to:
1
2
3
4
5
6
7
8
9
10
11
int main()  
{  
        int value;  
        do {  
               switch (value)  // Error: use of uninitialized variable
               {  
                     // code
               }
        } while (value != 0);  // Error: use of uninitialized variable 
        return 0;
 }
Topic archived. No new replies allowed.