Cin doesn't hold value

void GetSalesInfo(int accnum,//stores account number INPUT
int day,//stores day number INPUT
int month,//stores month number INPUT
int year,//stores year number INPUT
char countycode,//stores countycode INPUT
double totalsale,//stores sale cost before tax PROCESSING
int shippingweight);


Main(){
//all vars declared and initialized here

//this function gets input from the user and uses it later in other functions
//the problem I have here is that the input from the user that is stated
//in this function goes back to intitialized value when the function is over

//how do i fix this
GetSalesInfo(accnum,day,month,year,countycode,totalsale,shippingweight);



}




void GetSalesInfo(int accnum,//stores account number INPUT
int month,//stores day number INPUT
int day,//stores month number INPUT
int year,//stores year number INPUT
char countycode,//stores countycode INPUT
double totalsale,//stores sale cost before tax PROCESSING
int shippingweight)
{
cout << "Please Enter your Account Number: ";
cin >> accnum;
cout << "Please Enter the Sales Date.\n";
cout << "Enter Month: ";
cin >> month;
cout << "Enter Day: ";
cin >> day;
cout << "Enter Year: ";
cin >> year;
cout << "Please Enter the County Code: ";
cin >> countycode;
cout << "Please Enter the Sales Amount: ";
cin >> totalsale;
cout << "Please Enter the Weight:";
cin >> shippingweight;
cout << "\n\n\n";
}
Pass the parameters by reference, using the & operator.

#include <iostream>

void GetSalesInfo(int & accnum);

    using namespace std;

int main()
{

    int accnum = 0;
    GetSalesInfo(accnum);
    cout << "Account Number: " << accnum << endl;

    return 0;
}

//---------------------------------------------------

void GetSalesInfo(int & accnum)
{
    cout << "Please Enter your Account Number: ";
    cin >> accnum;
    cout << "\n\n\n";
}
Topic archived. No new replies allowed.