2017-03-26 15 views
-5

基本的にユーザーはPFCMOになることができる木材のタイプを入力します。ユーザーが 'T'を入力すると、ループは終了し、これまでのコードを出力します。私はアウトを出力するコードを書いていないが、出力が得られたかどうかを調べるためのテストと、ボイド関数ではユーザーからの入力が得られます。たとえば、P 10 10 10 10そのちょうどループが終了し、私が今まで持っていたものを取り除くべきならば。While Loop Not Working終了問題

#include <iostream> 
#include <iomanip> 
#include <string> 
using namespace std; 
void get_user_input(char&, int&, int&, int&, int&); 
float compute_item_cost(char, int, int, int, int); 
const float pine_cost = 0.89; 
const float fir_cost = 1.09; 
const float cedar_cost = 2.26; 
const float maple_cost = 4.50; 
const float oak_cost = 3.10; 
int main() 
{ 
    int quanity, height, width, length; 
    string name_of_wood; 
    char type;//declare variables 
    get_user_input(type, quanity, height, width, length); 


    do 
    { 
     get_user_input(type, quanity, height, width, length); 


    } while (type!='T'); 


    cout << "33333333333333333333333333333333333e"; 
    return 0; 

} 
void get_user_input(char& type, int& quanity, int& height, int& width, int& length) 
{ 
    cout << "Enter the wood type"; 
    cin >> type >> quanity >> height >> width >> length; 

} 

答えて

2

これを試してみてください:

void get_user_input(char& type, int& quanity, int& height, int& width, int& length) 
{ 
    cin >> type; 
    if (type == 'T') return; 
    cin >> quanity >> height >> width >> length; 
} 

それはCINのステートメントが終了する前に入力するあなたのためのすべての5つの値を待っているので、それが働いていない理由があります。

+0

ありがとう –