Thread: Access file's info in MINIX

  1. #1
    Registered User
    Join Date
    Jun 2007

    Access file's info in MINIX

    I want to make a new command in Linux(Minix) in C, for printing some info in the screen. The info is located in the file /etc/passwd and other files.
    The info is names logged in, in the system and other...
    I can use system() to open the file with vi editor but i don't know how to save something written in the file in a variable, so i can use it.
    Anyway, i don't know if any of these is right. If you have any other ideas, please help.

  2. #2
    Registered User
    Join Date
    Jun 2007
    Can i use fscanf() to access the file?
    For example the first line of the file may be: Zuko956:92555:something
    How can i store Zuko956 in a variable so i can use it?

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    You use the standard C file manipulation API, fopen(), fgets() and fclose(). Then you split the lines you read along the colons and you have the individual fields.

    Or you could use the actual passwd info API, like getpwent(), if MINIX supports it.
    All the buzzt!

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  4. #4
    Registered User
    Join Date
    Jun 2007
    Thanks once more!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Prevent access (FILES)
    By gavra in forum C Programming
    Replies: 34
    Last Post: 06-19-2008, 05:13 AM
  2. accessing files over wireless network
    By BobMcGee123 in forum Tech Board
    Replies: 4
    Last Post: 07-29-2006, 02:25 PM
  3. Linking header files, Source files and main program(Accel. C++)
    By Daniel Primed in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 11:46 AM
  4. Multiple Cpp Files
    By w4ck0z in forum C++ Programming
    Replies: 5
    Last Post: 11-14-2005, 02:41 PM
  5. Folding@Home Cboard team?
    By jverkoey in forum A Brief History of
    Replies: 398
    Last Post: 10-11-2005, 08:44 AM