home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_11_07
/
1107108a
< prev
next >
Wrap
Text File
|
1993-04-29
|
724b
|
31 lines
// comma.cpp: Extract comma-delimited tokens
#include <iostream.h>
#include <strstream.h>
#include <stddef.h>
main()
{
const size_t BUFSIZ = 128;
char s[BUFSIZ];
while (cin.getline(s,BUFSIZ))
{
char name[16], addr[26], city[16], state[5], zip[6];
istrstream sstr(s);
sstr.getline(name,sizeof name,',');
sstr.getline(addr,sizeof addr,',');
sstr.getline(city,sizeof city,',');
sstr.getline(state,sizeof state,',');
sstr.getline(zip,sizeof zip);
cout << name << '|'
<< addr << '|'
<< city << '|'
<< state << '|'
<< zip << endl;
}
return 0;
}