Thread: findfirst

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    14

    findfirst

    im struggling to get findfirst to work in C++ i am using Microsoft Visual C++. Trying to fing all gifs in a directory. I found this following code is the general way of achieving this....

    Code:
    #include <dos.h>
    #include <iostream>
    	int done;
    	struct ffblk ffblk;
    	done = findfirst("*.gif",&ffblk,0);
                  while(!done){
                         cout<<ffblk.ff_name;
                  }
    return 0;
    }
    where am i going wrong? and how can i change directories?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    Read the FAQ

  3. #3
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    #include <dos.h>
    VC++ compilers, and all other 32-bit compilers, do not suport any of the functions in dos.h. So you might as well delete that line from your program because it won't compile.

    To get a list of all the files in a directory, use _findfirst() and _findnext(), or FindFirstFile() and FileNextFile(). see www.msdn.microsoft.com or google for function details.

  4. #4
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. findfirst
    By jersey_gal in forum C Programming
    Replies: 14
    Last Post: 08-27-2008, 02:26 PM
  2. getting filenames
    By madsmile in forum C++ Programming
    Replies: 4
    Last Post: 03-12-2002, 02:40 PM
  3. findfirst, findnext question...
    By Brian in forum Windows Programming
    Replies: 2
    Last Post: 01-27-2002, 09:28 AM
  4. findfirst, findnext ??
    By Jamazon in forum C++ Programming
    Replies: 1
    Last Post: 10-24-2001, 12:48 PM
  5. findfirst, findnext.
    By Jamazon in forum C++ Programming
    Replies: 1
    Last Post: 10-22-2001, 10:59 PM