Getting just value from function

so I have a function that is returning a value (the input from a user) but when I am calling this function to another function, it is returning all the data within the function. How can I just get the return data from the user?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  //sample code
int main()
{
char A = H;
int B = 10;

newFunction(get_info(), A, B);

}

get_info();
{
string data;
cout << "enter string data" << endl;
cin >> data;

return data;
}


I don't want it to repeat the cout and cin.. I just need the string of data.
Thank you for any help
I don't understand.

Are you saying that you don't want the function get_info to use cin and cout? So where will the data come from?
sorry I didn't have connectivity and was trying to make this work with just my phone on limited access. Here is my problem,

1
2
3
4
5
6
7
8
string get_target()
{
	string part;
	cout << "What part number would you like to look for? \n";
	cin >> part;
	part[0] = toupper(part[0]);
	return part;  // agree this wast the function is returning? 
}


now what ever part read here.... I need it to go here:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

		else
		{
			cout << "Add this part? \n";
			cin >> choice;
			if (toupper(choice) == 'Y')
				get_more_data(class_in, part_ohb_in, part_cost_in);

                               //trining to get this data in here, so that it ca be sent to a vecort				 
                               insert_data(pVector, get_target(),class_in, part_ohb_in, part_cost_in);

				sort(pVector);

				bad++;
		}


my get_target function is returning the whole loop of the function again. when I just need the cin >> input.
Last edited on
Call get_target() just once and store the result in a variable.
1
2
3
4
5
string target = get_target();
...
newFunction(target, A, B);
insert_data(pVector, target, class_in, part_ohb_in, part_cost_in);
etc.
Topic archived. No new replies allowed.