c++ - Get the list of files in a directory with in a directory -


इस सवाल का पहले से ही एक उत्तर है: < / p>

  • 18 उत्तर

    मेरे पास " बेसफ़ाइल "के साथ इस निर्देशिका में, मेरे पास" Dir1 "," Dir2 "," Dir3 "आदि नामक निर्देशिकाएं हैं,

    इन सब-डायरेक्ट्रीज़ में, मुझे उन फ़ाइलों की सूची है जिनके लिए मुझे सूचीबद्ध होना चाहिए कोड के माध्यम से क्या कोई मुझे इस पर कुछ सुझाव दे सकता है?

    मुझे इसे विंडोज़ और लिनक्स प्लेटफार्मों में दोनों करने की ज़रूरत है ..

    आप इस प्रकार के कोड को opendir () और readdir () का उपयोग कर लिख सकते हैं

      #include & lt; dirent.h & gt; # शामिल करें & lt; stdio.h & gt; Int मुख्य (शून्य) {DIR * dirp; Struct dirent * निर्देशिका; Dirp = opendir ("/ home / user /"); अगर (डीआईआरपी) {जबकि ((निर्देशिका = रीडडीयर (डीआईआरपी)) = = नल) {printf ("% s \ n", निर्देशिका- & gt; d_name); } बंदर (डीआईआरपी); } वापसी (0); }    

Comments

Popular posts from this blog

asp.net - Procedure or function "Procedure name" expects a parameter "Param name" which was not supplied occurs rarely -

c# - The item with identity 'Id' already exists in the metadata collection. Parameter name: item -

c++ - Redefined variable in the other module -