Results 1 to 4 of 4

Thread: What is the output of this program?

  1. #1
    Senior Member
    Join Date
    Jul 2001
    Posts
    280

    What is the output of this program?

    I'm running this program, but I don't see any output. What do you get?

    Code:
    #include <stdio.h>
    #include <pwd.h>
    #include <unistd.h>
    
    int main (){
    
    
    struct passwd *p  = getpwuid (getuid());
    printf ("(%s)\n", p->pw_gecos);
    return 0;
    }
    # g++ test.cpp
    test.cpp:11:2: warning: no newline at end of file
    # ./a.out
    ()
    #
    There is no output. When I looked in pwd.h, it says the gecos field is the user's name. I guess I don't have a name

  2. #2

    Re:What is the output of this program?

    [quote author=t048 link=board=9;threadid=5313;start=0#51830 date=1034444262]
    I guess I don't have a name
    [/quote]

    Well fix that!
    Code:
    gorn:x:500:500:GoRN ToTheRescue:/home/gorn:/bin/bash
    the user's name is GoRN ToTheRescue, just put something in that field and you'll have a gecos.

  3. #3
    Senior Member
    Join Date
    Jul 2001
    Posts
    280

    Re:What is the output of this program?

    [quote author=gorn link=board=9;threadid=5313;start=0#51836 date=1034480984]
    [quote author=t048 link=board=9;threadid=5313;start=0#51830 date=1034444262]
    I guess I don't have a name
    [/quote]

    Well fix that!
    Code:
    gorn:x:500:500:GoRN ToTheRescue:/home/gorn:/bin/bash
    the user's name is GoRN ToTheRescue, just put something in that field and you'll have a gecos.

    [/quote]

    OK, thanks. Where is this field?

  4. #4
    Moderator
    Advisor
    redhead's Avatar
    Join Date
    Jun 2001
    Location
    Copenhagen, Denmark
    Posts
    811

    Re:What is the output of this program?

    in /etc/passwd

Similar Threads

  1. not getting top output when cron runs script
    By caligal in forum Linux - General Topics
    Replies: 1
    Last Post: 01-14-2007, 11:30 PM
  2. Using IPTABLES to block access to samba except certain IPs
    By addicted2linux in forum Linux - Software, Applications & Programming
    Replies: 1
    Last Post: 02-01-2006, 04:02 PM
  3. Windows Longhorn Release notes
    By regix in forum Windows - General Topics
    Replies: 0
    Last Post: 01-28-2005, 07:51 AM
  4. Program Compatibility Wizard in Windows XP
    By regix in forum Windows - General Topics
    Replies: 0
    Last Post: 01-04-2005, 07:43 AM
  5. IPTables stuff
    By tarballed in forum Linux - Software, Applications & Programming
    Replies: 8
    Last Post: 02-18-2003, 11:54 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •