Program won't run, can't figure out what's wrong...

Hi I am C++ student, and have a test coming up tomorrow, and while writing this program I got stuck, since it wont run... if you guys could help me out it would be great :)
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
  #include <iostream>
#include <string>
using namespace std;

enum type{l, p};

union pay{
	double pricel;
	int pricep;
};


struct Car{
	char model[20];
	int year;
	type typ;
	pay rate;
};
void assignValues(Car[], int num);
void displayValues(Car[], int num);


int main()
{
	Car * t;
	int numcars;
	cout << "Enter number of cars in stock: ";
	cin >> numcars;
	cin.ignore;
	t = new Car[numcars];
	assignValues(t, numcars);
	displayValues(t, numcars);
	delete[] t;
	return 0;
}

void assignValues(Car * t, int num)
{
	char ty;
	for (int x = 0; x < num; x++)
	{
		cout << "Car model name: ";
		cin.getline(t[x].model, 20);
		cin.ignore;
		cout << "Enter model year: ";
		cin >> t[x].year;
		cin.ignore;
		cout << "Lease (l or L) or Purchase (p or P): ";
		cin >> ty;
		if (ty == 'l' || ty == 'L')
		{
			t[x].typ = l;
			cout << "Enter monthly payment: ";
			cin >> t[x].rate.pricel;
			cin.ignore;
		}
		else if (ty == 'p' || ty == 'P')
		{
			t[x].typ = p;
			cout << "Enter purchase price: ";
			cin >> t[x].rate.pricep;
			cin.ignore;
		}
	}
}

void displayValues(Car * t, int num)
{
	for (int x = 0; x < num; x++)
	{
		cout << "Model: " << t[x].model;
		cout << "Year: " << t[x].year;
		if (t[x].typ == l)
			cout << "Leased at $" << t[x].rate.pricel;
		else if (t[x].typ == p)
			cout << "Purchased at $" << t[x].rate.pricep;
	}
}
It won't run

What errors do you get?
@shadowCODE

error C3867: 'std::basic_istream<char,std::char_traits<char>>::ignore': function call missing argument list; use '&std::basic_istream<char,std::char_traits<char>>::ignore' to create a pointer to member

it points to the cin.ignore on lines: 30, 45,48,56,63
cin.ignore(256,'\n');
Bro you are the best. Can u explain me why this works and regular cin.ignore wouldn't work, cause the way my teacher taught me is just to use regular cin.ignore.
"Regular cin.ignore" does work, but you have to actually call the function:

cin.ignore();
Last edited on
Besides, regular cin.ignore is not cin.ignore. it is cin.ignore().
http://www.cplusplus.com/reference/istream/istream/ignore/
Thanks a lot dude! what a silly mistake I made. -_-
Topic archived. No new replies allowed.