hi, can someone help me started with how to write a program that remove the comments from an input cpp file?

I am not even sure how to declare the function, like what would be the parameters?
and if I use
ifstream file;
file.open("text.cpp")

will the program treat that as a .text file?

Is this the right way to read the input before modified it?

void remove(int argc, char * argv[])
{
    ifstream fin;
    fin.open("test.cpp");
    string a  = *argv;
    while(fin)
    {
        getline(fin, a);
    }
    fin.close();
}

The key is to read the lines from test.cpp into a vector then only write back lines that dosen't start with "//" and you need to do some thinking on "/*" and "*/". Also there is no reason to pass the 2nd parameter, you can do all the read and write in the same method, and I also suggest:

void removeComments(string fileName){
ifstream fin;
fin.open(fileName.c_str());
.....
}

so you can pass in what file you want to remove the comments from.
G'Luck