home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / programm / 3183 < prev    next >
Encoding:
Text File  |  1992-11-18  |  1.5 KB  |  45 lines

  1. Path: sparky!uunet!charon.amdahl.com!pacbell.com!sgiblab!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!b63519.STUDENT.CWRU.Edu!dpn2
  2. From: dpn2@po.CWRU.Edu (Damien P. Neil)
  3. Newsgroups: comp.programming
  4. Subject: Re: Help!
  5. Date: Thu, 19 Nov 1992 00:59:02 GMT
  6. Organization: Case Western Reserve University
  7. Lines: 33
  8. Message-ID: <dpn2.112.722134742@po.CWRU.Edu>
  9. References: <1992Nov19.000103.27156@mnemosyne.cs.du.edu>
  10. NNTP-Posting-Host: b63519.student.cwru.edu
  11.  
  12. In article <1992Nov19.000103.27156@mnemosyne.cs.du.edu> nogurtso@nyx.cs.du.edu (Nick Ogurtsov) writes:
  13. >I have a problem. I'm new in C language, so can anyone help me?
  14. >Could anyone write a piece of C code to show how to use findfirst()?
  15. >
  16. >Could anyone show me how to display found file name on the screen? (from
  17. > ffblk.fname).
  18.  
  19. Are you using Borland/Turbo C, by any chance? If so, there is some good 
  20. example code in the help system. Here it is: (Borland won't get mad at me 
  21. for posting an insignificant fragment like this, will they?)
  22.  
  23. /* findfirst and findnext example */
  24.  
  25. #include <stdio.h>
  26. #include <dir.h>
  27.  
  28. int main(void)
  29. {
  30.    struct ffblk ffblk;
  31.    int done;
  32.    printf("Directory listing of *.*\n");
  33.    done = findfirst("*.*",&ffblk,0);
  34.    while (!done)
  35.    {
  36.       printf("  %s\n", ffblk.ff_name);
  37.       done = findnext(&ffblk);
  38.    }
  39.  
  40.    return 0;
  41. }
  42. +-------------+------------------+---------------------------------+
  43. | Damien Neil | dpn2@po.cwru.edu | Case Western Reserve University |
  44. +-------------+------------------+---------------------------------+
  45.