"Fossies" - the Fresh Open Source Software Archive

Member "erltools/pub/cplusplu/test/bug.c_l" (25 Jul 1999, 694 Bytes) of package /linux/misc/old/erltools-4.0.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #include "User.h"
    2 #include "Collection.h"
    3 #include <iostream.h>
    4 #include <strstream.h>
    5 #include <fstream.h>
    6 #include <string.h>
    7 const int BUFFERSIZ = 256;
    8 
    9 class UserCollection : public Collection {
   10     
   11     private :
   12         User *new_user;
   13     
   14     public :
   15         UserCollection ();
   16 
   17 };
   18 
   19 UserCollection::UserCollection () {
   20 
   21     char buffer [BUFFERSIZ],
   22          *user;
   23 
   24         try {
   25 
   26         ifstream passwd("/etc/passwd");
   27     
   28         while (passwd.getline(buffer, sizeof(buffer) - 1) != NULL) {
   29 
   30             user = strtok(buffer, ":");
   31             new_user = new User(user);
   32             push(new_user);
   33 
   34         }
   35 
   36     }
   37          catch (...) {
   38             cout << "UserCollection: invalid /etc/passwd\n";
   39         } 
   40 
   41 }
   42