Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Reading Directory

Reading Directory

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Fareed Rizkalla
    wrote on last edited by
    #1

    #include
    #include

    using std::cin;
    using std::cout;
    using std::endl;

    void main()
    {
    WIN32_FIND_DATA FileDetails;
    HANDLE ListDirectory;
    ListDirectory = FindFirstFile(L"C:\\*", &FileDetails);
    cout << FileDetails.cFileName << endl;
    FindClose(ListDirectory);
    }

    I read on MSDN the code is deprecated on Windows 7! Any ideas why it is giving me junk text as a result. Does anyone also know a 1 line fix for the 3 using declarations?

    C _ 2 Replies Last reply
    0
    • F Fareed Rizkalla

      #include
      #include

      using std::cin;
      using std::cout;
      using std::endl;

      void main()
      {
      WIN32_FIND_DATA FileDetails;
      HANDLE ListDirectory;
      ListDirectory = FindFirstFile(L"C:\\*", &FileDetails);
      cout << FileDetails.cFileName << endl;
      FindClose(ListDirectory);
      }

      I read on MSDN the code is deprecated on Windows 7! Any ideas why it is giving me junk text as a result. Does anyone also know a 1 line fix for the 3 using declarations?

      C Offline
      C Offline
      Cool_Dev
      wrote on last edited by
      #2

      Your code seems unicode, thats why cout prints junk. use unicode version as wcout<

      1 Reply Last reply
      0
      • F Fareed Rizkalla

        #include
        #include

        using std::cin;
        using std::cout;
        using std::endl;

        void main()
        {
        WIN32_FIND_DATA FileDetails;
        HANDLE ListDirectory;
        ListDirectory = FindFirstFile(L"C:\\*", &FileDetails);
        cout << FileDetails.cFileName << endl;
        FindClose(ListDirectory);
        }

        I read on MSDN the code is deprecated on Windows 7! Any ideas why it is giving me junk text as a result. Does anyone also know a 1 line fix for the 3 using declarations?

        _ Offline
        _ Offline
        _Superman_
        wrote on last edited by
        #3

        The using keyword is used as follows -

        #include <iostream>
        using namespace std;

        «_Superman_»
        I love work. It gives me something to do between weekends.

        Microsoft MVP (Visual C++)

        Polymorphism in C

        A 1 Reply Last reply
        0
        • _ _Superman_

          The using keyword is used as follows -

          #include <iostream>
          using namespace std;

          «_Superman_»
          I love work. It gives me something to do between weekends.

          Microsoft MVP (Visual C++)

          Polymorphism in C

          A Offline
          A Offline
          Aescleal
          wrote on last edited by
          #4

          It's only used that way if you want to dump the whole of the std:: namespace into your code. You can also use it on individual identifiers (as the original poster did) and to change the visibility of class members. Ash

          _ 1 Reply Last reply
          0
          • A Aescleal

            It's only used that way if you want to dump the whole of the std:: namespace into your code. You can also use it on individual identifiers (as the original poster did) and to change the visibility of class members. Ash

            _ Offline
            _ Offline
            _Superman_
            wrote on last edited by
            #5

            Fareed Rizkalla wrote:

            Does anyone also know a 1 line fix for the 3 using declarations?

            This made me think the OP wanted it so.

            «_Superman_»
            I love work. It gives me something to do between weekends.

            Microsoft MVP (Visual C++)

            Polymorphism in C

            A 1 Reply Last reply
            0
            • _ _Superman_

              Fareed Rizkalla wrote:

              Does anyone also know a 1 line fix for the 3 using declarations?

              This made me think the OP wanted it so.

              «_Superman_»
              I love work. It gives me something to do between weekends.

              Microsoft MVP (Visual C++)

              Polymorphism in C

              A Offline
              A Offline
              Aescleal
              wrote on last edited by
              #6

              Good point! Next stop I'll be starring on the muppet show. Ash

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups