reading from a fie with classes

1
2
3
4
5
6
7
8
9
10
11
12
13
#ifndef stockTab_h
#define stockTab_h
#include "media.h"


class StockTab {
public:
	StockTab ();     // Default Constructor.
private:
	int itemCount;   //number of stock items currently available
	Media **mptr;      // table of pointers to media objects. The last entry is NULL
}; 
#endif 

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
#include "stockTab.h"
#include <iostream>
#include <fstream>
using namespace std;

StockTab::StockTab()
{
	int size;
	char line[50];
	ifstream in ("stock.txt");
	if(in.fail())
	{
		cout<<"file open failed"<<endl;
		exit(1);
	}
	in>>size;
	itemCount = size;
	mptr = new Media *[itemCount];
	char *tokptr = strtok(mptr,'/');
	while (!in.eof())
	{
		in>>line;
		while(tokptr!=NULL)
		{
			for(int i=0;i<itemCount;i++)
			{
				mptr[i] = new Media;
			}
		}
	}
}


this will read data from a file example and needs to store in a pointer and tokenize it.....but it gives an error!!!
5
4/Gone with the wind/Sharon Stone/2005/35683546/S
The first argument to strtok should be of type char*, not Media**.
Topic archived. No new replies allowed.