Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

Can someone complete the following C++ program?

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

user-image
Question added by Adeeb Haddad , Independent Freelance Translator , Independent
Date Posted: 2013/12/31
Yogesh Dhakad
by Yogesh Dhakad , Director Technical , Timeless Horizon Engineering Solutions

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.

KASHIF ZEESHAN
by KASHIF ZEESHAN , Corporate Trainer , ORION EDUTECH PVT LTD

Is this the complete program only edits required or you want it to be structured with more cases and statements

 

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.