Rewrite ls (linux) in C

Hello,
I have a project to complete, which is to recode the "ls" command found in Linux.
Okay, this topic has already been addressed in other threads, but the problem is that we are not allowed to use printf, scanf, and all the other functions that would simplify our lives.
I have absolutely no idea where to start. Thank you in advance.

4 answers

  1. At Epitech, we've already covered this topic; I think it’s more like 42 ;)
    0
    1. possible !
      0
  2. You, you are at Epitech, you!

    Start by recoding getchar and putchar, functions that allow you to respectively get and display a character.

    Then, look towards the system APIs to list a directory.

    Finally, you will need to work with structures and linked lists...

    I'll leave you to search!

    --
    ------------------------------------------------------------------------------------
    "Fear leads to anger. Anger leads to hate. And hate... leads to suffering." - Yoda
    0
    1. Good evening
      To begin with, "LS" is not a function but a program that we call to list a directory and which takes arguments, and if other functions are prohibited for you, then you can use write for example

      --
      All knowledge is an answer to a question.
      0
      1. Contributor
        Nobody said that it was a function ;-).
        Then you have to see if fwrite() or write() is allowed...
        And others too like readdir() and so on.
        0
      2. Not wrong :-)
        but well, if it's just printf and the like that shouldn't be used, the rest is allowed.
        0
      3. Contributor
        It all depends on what "company" means... I'm particularly thinking of system functions.
        0
      4. So if that's the case, let's go through the function
         int printk() 

        but be careful, this one is reserved for the system itself, the kernel, drivers, etc.
        0
      5. Contributor
        If system functions are allowed, then use the write() function which has the advantage of being POSIX. Hence my very first post :-))).
        0
    2. Contributor
      Hello,

      You need to see exactly what you are allowed...
      System function (like read())? A few standard functions (like fread())?
      Etc.
      Best regards,
      --

      Google is your friend
      0