Hi all. this is my first post. I think (and you will tend to agree with me later) that I really need to work on my programming technique . I will need to do some coding in python for my MS later this year and want to be in the proper programming frame of mind for that.
Have a look at my snippet code and please critique me as heavily as possible.
Background: I have network shares for lecturers to upgrade their documents to. Since some of them are not really interested in computers, this prog loads their shares as mapped drives.
Two pcs, public pc houses the database and is accessible without providing credentials, and privatepc houses their documents and accessible only with credentials. Mapped drives start at u: and end at y:.
EDIT: Forgot to add. I am using console command
to map \\server\share to h: using the credentials of hypothetical user "shareuser"Code:net use h: \\server\share /user:shareuser
C++ code:
database fileCode:#include <iostream> #include <string> #include <fstream> #include <conio.h> using namespace std; int main() { string userName, line="", link="net use "; //line - to get a line from database file. /*link - string adding in c needs oper- ation of the form string = string + whatever. so system call at ** needs proper string operation */ int i=117; /*mapped drives start at u: going to y: depending on number of drives to be mapped. char (117) = u*/ fstream courses; //for smiple database text file system ("copy \\\\publicpc\\general\\courses"); //location of database file "courses" courses.open ("courses"); cout << "Please enter your username: "; cin >> userName; if (courses.is_open()) { while (userName!=line&&!courses.eof()) { getline(courses, line); } if (userName==line) { do { system((link + (char (i)) + ": \\\\privatepc\\"+line+" /persistent:no /user:"+userName).c_str()); //** i++; getline (courses, line); } while (line!="*" && i<122); // * signifies end of shares for that user, 122 = char (z) courses.close(); } else cout << "It seems that you are not in the lecturer database. Please contact the administrator" << endl; } else cout << "Cannot open database. Please inform the administrator!"; system ("del courses"); while (!kbhit()) {} //minimise system calls return 0; }
Code:lecturer1 maths100 maths200 * lecturer2 apm100 apm200 * lecturer3 num100 * etc.



1Likes
LinkBack URL
About LinkBacks


