Forward-c++ implement find files under folder

Source: Internet
Author: User

[CPP] View plain copy on code to view the snippet derived to my code slice began to think it was a very simple problem later found a little trouble, finally implemented as follows, where TMP is the type of file to find, change to other such as. java can find Java type file name [CPP ] View plain copy on code to see a snippet derived from my Code slice <pre code_snippet_id= "266604" snippet_file_name= "blog_20140331_2_3829526"  Name= "code" class= "CPP" > #include <iostream> #include <dirent.h> using namespace std;      int main (void) {dir* dirp;      struct dirent* direntp;      DIRP = Opendir ("F:\\output\\codegen");      string tmp = ". txt";      string filename; if (dirp! = NULL) {for (;;)              {direntp = Readdir (DIRP);              if (direntp = = NULL) break;              string s = direntp->d_name;                         int x = S.find (tmp,0);          if (x>0) {string last;          Last.assign (S,0,X);          Filename=last;      FileName is the name of the TXT file, does not contain the TXT suffix, and the added. txt suffix after the name can be opened directly for other operations}} closedir (DIRP);    } cout<<filename<<endl;  return 0;        }</pre><br> <br> <pre></pre> <pre></pre>

  

Forward-c++ implement find files under folder

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.