unix ls in c code?

This is a discussion on unix ls in c code? within the C Programming forums, part of the General Programming Boards category; i was wondering if there was a way to run an ls, possibly with system(), and read the results in ...

  1. #1
    Registered User
    Join Date
    Jan 2011
    Posts
    2

    unix ls in c code?

    i was wondering if there was a way to run an ls, possibly with system(), and read the results in an array of let's say char*'s. I need to get a list of filenames from a directory

  2. #2
    Registered User
    Join Date
    Feb 2010
    Posts
    84

    tag

    tag.

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    23,787
    Look into the use of readdir and related functions.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #4
    Registered User
    Join Date
    Jan 2011
    Posts
    2
    thanks laserlight
    those seem to be exactly what im looking for

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. I lost the Source Code
    By onalethata in forum Tech Board
    Replies: 9
    Last Post: 11-05-2010, 04:00 PM
  2. Values changing without reason?
    By subtled in forum C Programming
    Replies: 2
    Last Post: 04-19-2007, 10:20 AM
  3. Explain this C code in english
    By soadlink in forum C Programming
    Replies: 16
    Last Post: 08-31-2006, 12:48 AM
  4. source code for ls, kill and ps
    By jon21 in forum Linux Programming
    Replies: 2
    Last Post: 04-07-2002, 10:55 AM
  5. Replies: 4
    Last Post: 01-15-2002, 11:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21