how can separate the date from input file into arrays?

how can read the date saprate from input file into 4 dynamically arrays without the '/'
the input file is like :

2 // the size of file
shoa say/1111/2700/4/
jona fox/1112/2000/3/

the arrays ara string name,int account,int balance,int number
how can but each element in the arrays

this is my function code to read from the file

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

void readfile(string *&name,int *&account,int *&balance,int *&num,int &size)
{
	fin.open("accounts.txt");
	if(!fin)
	{
		cout<<"Error reading file account.txt\n";
		exit(1);
	}
	fin>>size;
	cout<<size<<endl;
	name = new string[size];//creates name dynamic array
	account = new int[size];//creates  dynamic array
	balance = new int[size];
	num = new int[size];
	
	for(int i=0; i<size; i++)
	{
		getline(fin,name[i]);
		fin>>account[i]>>balance[i]>>num[i];
		cout<<name[i];//<<account[i]<<balance[i]<<num[i]<<endl;
		
	}

}

If your compiler is recent enough and supports C++11 well enough, I suggest you look into the regex library.
http://cplusplus.com/reference/regex/

Otherwise use std::getline() and specify the character '/' as the delimiting character (default is '\n').
http://cplusplus.com/reference/istream/istream/getline/
Topic archived. No new replies allowed.