Hi guys,
im new in C++ programming and hope anyone could guide me to understand C++ and be able to code my assignment out :)

what the program does:
1. user inputs text file name,
2. user inputs key word
3. program goes about replacing character/strings in the text file with a formula(encrypt/decrypt)
4. output is displayed and save as another file name

so far i've done part 1, could some one guide me what should i use?
vectors or array to go about replacing or??

code as follows.....

#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main()
{
    ifstream fin;
    string name;
    string x;
    string s;
    char t
    int mark;
    
    
    do
    {
        cout << "Enter filename: ";
        cin >> x;
        cout << "You filename: " << x << endl;
        
        fin.open(x.c_str());
        
        if(x=="exit") {
            return(0);
           }

         
             if (!fin.good())
             {
                    cout << "File not found" << endl;
                    system("pause");
                    fin.clear();        
             }

             else
	         {

	                while(!fin.eof())
	                {
                             getline(fin, s);
                             cout << t << endl;

                    }
             }
             fin.close();
             fin.clear();
    }
    while(true);
    system("pause");
    return 0;

}

Edited 7 Years Ago by zackie: n/a

Seeing as you are using std::strings I would look into using the string replace method.

Also beware of using eof to read files it has a hidden gotcha.

This article has been dead for over six months. Start a new discussion instead.