HELP Please! What am I doing Wrong??

Hello, this program is supposed to take the user's "desired car" input (model,mileage and price) and compare it to cars in an inventory file (current_inventory). I need to do this using two functions: get_next_auto(to take the next car from the inventory until the end of the file) and compare_auto(compare the inventory car to the user's requirements) at the end the program should read out how many cars from the inventory met the user's requirements. So far this program compiles, but after typing in the user's model, mileage and price it doesn't do anything and seems to be going through an indefinite loop. Will someone please help me figure out what I am doing wrong? Thanks a lot I really appreciate 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include <iostream>
#include <cstdlib>
#include <fstream>
using namespace std;

struct car {
	int make;
	int mileage;
	double price;
	};
	

int main()
{
		
	ifstream in_stream;		
	ofstream out_stream;
	int num_acceptable;
	car usercar, inventorycar;

	bool get_next_auto(); 
	bool compare_auto();
	
in_stream.open("./current_inventory");
	if (in_stream.fail())
	{
	cout << "Input file opening failed.\n";
	exit(1);
	}

out_stream.open("./proj3.out");
	if (out_stream.fail())
	{
	cout << "Output file opening failed.\n";
	exit(1);
	}


	cout << "Please describe the car you are looking for:\n";
	cout << "  1: Chevrolet\n ";
	cout << " 2: Ford\n ";
	cout << " 3: Honda\n ";
	cout << " 4: Toyota\n ";
	cout << " 5: Porsche\n ";
	cout << "\n";
	cout << "Please select your make: ";
	cin  >> usercar.make;
	cout << "Please enter a maximum acceptable mileage and price. ";
	cin  >> usercar.mileage >> usercar.price;

	
	num_acceptable = 0;

	get_next_auto();

	compare_auto();

	
	if (num_acceptable == 1)
		{
		cout << " There is " << num_acceptable << " car that matches your description. Have fun test driving!\n\n";
		}
	else
		{
		cout << " \nThere are " << num_acceptable << " cars that match your description. Have fun test driving!\n\n ";
		}
	return(0);
}

	bool compare_auto()
{
	bool get_next_auto;
	ifstream in_stream;		
	int num_acceptable;
	car usercar, inventorycar;

	
	in_stream >> inventorycar.make >> inventorycar.mileage >> inventorycar.price;

		if ((inventorycar.make == usercar.make) && (inventorycar.mileage <= usercar.mileage) && (inventorycar.price <= usercar.price));
		{
			num_acceptable++;
			
		}
		
		

}	
	bool get_next_auto()
{
	bool compare_auto;
	ifstream in_stream;		
	car usercar, inventorycar;

	{
		while(!in_stream.eof())
			{
			compare_auto;
			}
	}
}
It might help you to figure it out if you did not use the same names for different items. i.e. you have a function called compare_auto and then you declare a boolean called compare_auto within get_next_auto, you then reference it again in the while loop in the same function... not really easy to determine what you want to do.

This is probably what is confusing you with the int num_acceptable, it is not a global variable, so the value is not known between functions... you can place it outside the functions at the top of the file or pass the value as part of the function return.
I am trying to make my function get_next_auto to run the function compare_auto until the end of file how do i do this? what should i change can you please show me?
Topic archived. No new replies allowed.