Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void fileInput()
- {
- ifstream f_in;
- int choice3;
- string loc, line;
- printf("\nEnter File location: ");
- cin >> loc;
- f_in.open(loc.c_str());
- if (f_in.is_open())
- {
- while (getline(f_in,line))
- {
- printf("\n1. Convert to Prefix \n");
- printf("2. Convert to Postfix \n");
- printf("\nEnter your choice:");
- cin >> choice3;
- if (choice3 == 1)
- {
- prefixConverter(line);
- }
- else if (choice3 == 2)
- {
- postfixConverter(line);
- }
- }
- }
- else
- {
- std::cout << "Unable to open file" << std::endl << std::endl;
- }
- f_in.close();
- ofstream f_out;
- f_out.open(loc.c_str());
- if (choice3==1)
- {
- f_out << result1 << endl;
- cout << "Output written in File." << endl;
- result1.clear();
- result2.clear();
- }
- else if (choice3==2)
- {
- f_out << result2 << endl;
- cout << "Output written in File." << endl;
- result1.clear();
- result2.clear();
- }
- f_out.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement