Register now or log in to join your professional community.
184 folders named (1-184) text file with184 lines The program should rename the folders and replace them with new name (the lines inside the text file) #include <iostream> #include <fstream> #include <string> #include <dirent.h> using namespace std; int main() { DIR * dir = opendir("J:\\Folder_Name\\") ifstream inFile ("desiredName.txt"); string line, oldFile, newFile; inFile.open(); if (!dir) cout << "Error opening directory." << endl; else { struct dirent *entry; while (entry = readdir(dir)) { oldFile = entry->d_name; if ( !inFile.is_open() ) cout << "Failed to open input file." << endl; else { getline(inFile, line); cout << line << endl; newFile = line; } if (newFile.size() ==0; cout << "File read error." << endl; //here is where I get stuck
a) Pl structure the code properly before you submit your question.
b) Such simple things deserve to use a simple language like "python".
c) C++ can ultimate do everything so look at my a). Resubmit.
Is this the complete program only edits required or you want it to be structured with more cases and statements