want to return multiple values

can anyone help me,
I AM A BEGINNER i want to return account number(num_acc) also with number of iteration(i).. and want to use them in parent code for further process .. want your help.. give code in a simple and easy manner..

int check_acc_num(int count)
{
int num_acc;
cout << "From which account you want to edit details??\n" << "Enter Account Number: ";
cin >> num_acc;

for(int i = 0; i < count ; i++)
{
if(num_acc == info[i].acc_no)
{
system("color 27");
return i;
}
}
system("color 47");
cout << "*****ERROR: INVAILD ACCOUNT NUMBER*****\n";
system("PAUSE");
return -1;
}

Thanks
Faizan
Last edited on
If you need your function to pass back multiple outputs, you need to have them as arguments to the function, and pass them by reference.

EDIT: Also, please use code tags when posting code, to make it readable:

http://www.cplusplus.com/articles/z13hAqkS/
Last edited on
I suspect that you don't need to return the account number. The caller can get it from info easily enough:
1
2
3
4
5
6
int index = check_acc_number(count);
if (index >= 0 {
    cout << "account number " << info[index].acc_no << '\n';
else {
    cout << "no account found\n";
}


i get that @dhayden
thanks for helping me :)
thanks alot
Whe can send more than just an integer, think of object created from struct or class containing multiple data.
Topic archived. No new replies allowed.