Help with Structures

Im getting a "terminate called after throwing an instance" error. I just started writing a program for a homework assignment. So far, Im trying to store stuff into a structure from an input file. Here are the exact contents of the input file, if you want to test it:

chocolate, 10, 4.50
roses, 15, 10.50

Can someone tell me whats wrong? THanks.

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
  #include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cctype>
#include <cstdlib>
#include <vector>

using namespace std;

struct Inventory
{
    string name;
    int available;
    double price;
};

Inventory* readFile(int & count);



int main()
{
    int count = 0;
    readFile(count);


    return 0;
}

Inventory* readFile(int & count)
{
    char filename [81];
    ifstream inFile;
    string temp;
    int beg;
    int i = 0;

    cout << "Enter the filename: ";
    cin >> filename;
    cout << endl;

    inFile.open(filename);

    while (!inFile)
    {
        cout << "Enter a valid file name: ";
        cin >> filename;
        inFile.open(filename);
    }

    while (inFile >> temp)
    {
        count++;
    }

    inFile.clear();
	inFile.seekg(0, ios::beg);

	Inventory* items = new Inventory[count];

    while (inFile >> temp)
    {
        beg = 0;
        items[i].name = temp.substr(beg,temp.find(","));
        beg = temp.find(",");
        (temp.find(",",beg)).c
        items[i].available = atoi((temp.substr(beg,temp.find(",",beg))).c_str());

    }

    cout << items[0].name << endl << items[0].available << endl;

    return items;

}


67: (temp.find(",",beg)).c
That does not look complete...
Topic archived. No new replies allowed.