a c progam source code needed

Discussion in 'Open Source' started by simplegeek, Dec 19, 2004.

Thread Status:
Not open for further replies.
  1. simplegeek

    simplegeek New Member

    Joined:
    Nov 28, 2004
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    0
    hi

    i am working on a simple home based c project. I am a beginner in this and need a c program which when invoked will give me the names of the files in the directory.

    This should be accomplished by giving me the single name of the file as a variable, so i can manupulate or sort them as i want.

    just a simple basic code will do.

    thanks for ur time
     
  2. cnukutti

    cnukutti New Member

    Joined:
    Feb 10, 2004
    Messages:
    99
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Chennai,India
    I really cant understand your question.
    If you wanted to display all the files in the current directory, you can pass the ls command to a function called system()

    Code:
    #include<stdio.h>
    main()
    {
        system("ls");
    }
    
    If this is not what you expected, then please reframe your question.
     
  3. nixcraft

    nixcraft New Member

    Joined:
    Nov 16, 2004
    Messages:
    101
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    BIOS
    LOL it is better to use ls. Anywasy see source code of ls it will guide you as well as teach you more :D
     
Thread Status:
Not open for further replies.

Share This Page