SilkyFalcon

Generation

generate functionWed, 07 Dec 2022

open every file in a specific folder than open all of them and write "Coded by Inventex" to the first line as a comment

#include <iostream> #include <fstream> #include <dirent.h> using namespace std; int main() { DIR *dir; struct dirent *ent; if ((dir = opendir ("C:/Users/Inventex/Downloads/Code")) != NULL) { while ((ent = readdir (dir)) != NULL) { string name = ent->d_name; if(name.find(".txt") != string::npos) { ofstream outfile; outfile.open("C:/Users/Inventex/Downloads/Code/"+name); outfile << "//Coded by Inventex" << endl; outfile.close(); } } closedir (dir); } else { cout << "Could not open the folder" << endl; } return 0; }

Questions about programming?Chat with your personal AI assistant