Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

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 ajoutée par Adeeb Haddad , Independent Freelance Translator , Independent
Date de publication: 2013/12/31
Yogesh Dhakad
par 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
par 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

Avez-vous besoin d'aide pour créer un CV ayant les mots-clés recherchés par les employeurs?