Results 1 to 6 of 6

Thread: FindFirst and Next help

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Columbus Ohio
    Posts
    217
    If I try this:
    [code]
    #include <iostream.h>
    #include <windows.h>

    void main()
    {
    WIN32_FIND_DATA data;
    FindFirstFile("c:/*.cpp",&data);
    cout<<&data;

    }
    [code]
    I get a number that looks like a memory address. How can I extract the filename??
    Chris

    [email protected]
    Windows XP RC2 B2526
    Visual Studio.Net Beta 2
    C++, VB, VB.Net, ASP, PHP

  2. #2
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    No no . You can't print data. Data is a WIN32_FIND_DATA structure now. To get the filename use:
    Code:
    cout<<data.cFileName;
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Columbus Ohio
    Posts
    217

    hmm

    When i tried that b4 it printed a wierd symbol
    Chris

    [email protected]
    Windows XP RC2 B2526
    Visual Studio.Net Beta 2
    C++, VB, VB.Net, ASP, PHP

  4. #4
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    That is because maybe there are no cpp files in that dir. I tried this code and it works. If there are cpp files it prints the file name of the first one else it prints nothing.
    Code:
    WIN32_FIND_DATA data;
    if(FindFirstFile("c:/*.cpp",&data) != INVALID_HANDLE_VALUE) 
    {
    cout<<data.cFileName;
    }
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Columbus Ohio
    Posts
    217

    thanks

    Ill try that
    Chris

    [email protected]
    Windows XP RC2 B2526
    Visual Studio.Net Beta 2
    C++, VB, VB.Net, ASP, PHP

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Columbus Ohio
    Posts
    217

    My syntax

    My syntax is like that but findnext in a loop will only return the first file. Any ideas?
    Chris

    [email protected]
    Windows XP RC2 B2526
    Visual Studio.Net Beta 2
    C++, VB, VB.Net, ASP, PHP

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width