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 >
Text File  |  1993-04-29  |  724b  |  31 lines

  1. // comma.cpp:   Extract comma-delimited tokens
  2. #include <iostream.h>
  3. #include <strstream.h>
  4. #include <stddef.h>
  5.  
  6. main()
  7. {
  8.     const size_t BUFSIZ = 128;
  9.     char s[BUFSIZ];
  10.     
  11.     while (cin.getline(s,BUFSIZ))
  12.     {
  13.         char name[16], addr[26], city[16], state[5], zip[6];
  14.         istrstream sstr(s);
  15.  
  16.         sstr.getline(name,sizeof name,',');
  17.         sstr.getline(addr,sizeof addr,',');
  18.         sstr.getline(city,sizeof city,',');
  19.         sstr.getline(state,sizeof state,',');
  20.         sstr.getline(zip,sizeof zip);
  21.         cout << name << '|'
  22.              << addr << '|'
  23.              << city << '|'
  24.              << state << '|'
  25.              << zip << endl;
  26.     }
  27.     
  28.     return 0;
  29. }
  30.  
  31.