What do I do wrong?

Kurtis D. Rader krader at crg8.sequent.com
Fri Dec 14 06:36:14 AEST 1990


In article <1990Dec13.023035.19793 at IRO.UMontreal.CA> quennevi at IRO.UMontreal.CA (Charles Quenneville) writes:
%Could you tell me what is wrong with this program? All I'm trying to do
%is simply to print the username. 
%
%#include <pwd.h>
%#include <stdio.h>
%
%main ()
% {
%  struct passwd *pwd;
%  struct passwd *getpwent();

Doesn't pwd.h include a declaration for getpwent(3)?

%
%  setpwent("/etc/passwd");

At least in BSD 4.2 setpwent(3) doesn't take any arguments, so this
should be

	setpwent();

%  while ((pwd = getpwent()) != 0)
%   {
%    printf("\n", pwd->pw_name);

Try

	printf ("%s\n", pwd->pw_name);

%    fflush(stdout);
%   }
%  endpwent("/etc/passwd");

Likewise, endpwent(3) doesn't take any arguments either.

% }
--
Kurtis D. Rader, Technical Support Engineer    voice:    503/578-3714
Service Hotline, Sequent Computer Systems      fax:      503/578-3731
15450 SW Koll Parkway, M/S UMP2-502            UUCP:     ...uunet!sequent!krader
Beaverton, OR  97006-6063                      internet: krader at sequent.com



More information about the Comp.unix.internals mailing list