Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Ispis datoteka u C-u

[es] :: C/C++ programiranje :: Ispis datoteka u C-u

[ Pregleda: 3344 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

BoLa
Software Developer
Sarajevo

Član broj: 7535
Poruke: 78
85.158.39.*



Profil

icon Ispis datoteka u C-u12.01.2006. u 16:31 - pre 222 meseci
Zanima me koja funkcija vrsi sljedece u C-u: vraca imena datoteka u zadanom direktoriju(kao dir u dosu)? Da li postoji takva funkcija? Koristim borland c++ 5.02.

Pregledao sam dosta zaglavlja ali nisam nasao odgovarajucu funkc.
 
Odgovor na temu

X Files
Vladimir Stefanovic
Pozarevac

SuperModerator
Član broj: 15100
Poruke: 4902
*.nat-pool.po.sbb.co.yu.

Jabber: xfiles@elitesecurity.org


+638 Profil

icon Re: Ispis datoteka u C-u12.01.2006. u 18:18 - pre 222 meseci
Pogledaj u Help-u funkcije findfirst(), findnext(), ...

Ovo je copy/paste primer iz BCB Helpa (C Runtime Library Reference), i trebao
bi da se bez problema kompajlirta sa BC 5.02.

Pogledaj detaljnije (takodje u Help-u) 'ffblk' strukturu, koja ima i vise podataka
od samog imena, koje primer ispisuje...

Code:

/* findfirst and findnext example */

#include <stdio.h>
#include <dir.h>

int main(void)
{
   struct ffblk ffblk;
   int done;
   printf("Directory listing of *.*\n");
   done = findfirst("*.*",&ffblk,0);
   while (!done) 
   {
      printf("  %s\n", ffblk.ff_name);
      done = findnext(&ffblk);
   }

   return 0;
}
 
Odgovor na temu

BoLa
Software Developer
Sarajevo

Član broj: 7535
Poruke: 78
85.158.39.*



Profil

icon Re: Ispis datoteka u C-u12.01.2006. u 18:26 - pre 222 meseci
Da, mislim da je to sto je trebalo. Ja sam takodjer nasao jos nesto na netu.

Code:

main()   { int count,i;
                struct direct **files;
                int file_select();
 
                if (getwd(pathname) == NULL )
                        { printf("Error getting path$\backslash$n");
                                exit(0);
                        }
                printf("Current Working Directory = %s$\backslash$n",pathname);
                count =
                  scandir(pathname, &files, file_select, alphasort);
 
                /* If no files found, make a non-selectable menu item */
                if         (count <= 0)
                        {         printf(``No files in this directory$\backslash$n'');
                                exit(0);
                        }
                printf(``Number of files = %d$\backslash$n'',count);
                for (i=1;i<count+1;++i)
                         printf(``%s  '',files[i-1]->d_name);
                printf(``$\backslash$n''); /* flush buffer */
        }


ova linija:

count = scandir(pathname, &files, file_select, alphasort);
Pa cu probati ...

Zaboravih include je ovo:
#include <sys/types.h>
#include <sys/dir.h>
#include <sys/param.h>
#include <stdio.h>

[Ovu poruku je menjao BoLa dana 12.01.2006. u 19:27 GMT+1]
 
Odgovor na temu

[es] :: C/C++ programiranje :: Ispis datoteka u C-u

[ Pregleda: 3344 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.