How to divide a string into pieces.

Hi guys,

I have a text file in which lines look like this:

string, int string.

And i would like to divide it and send every element to its structure.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

#include "stdafx.h"
#include <iostream>
#include <string>
#include <fstream>
#include <cstdio>
#include <iomanip>

using namespace std;

struct address
{
	string street;
	int zip;
	string city;
};
istream & operator >>(istream & in, address & ad)
{
	string temp;
	getline(in);
	
	return in;
}
Last edited on
For this, I would look at the standard regular expression library (introduced in C++11). Google is your friend.
Topic archived. No new replies allowed.