Why doesn't my program accept "quit" when I input it?

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


using namespace std; 
int main()

{
    ifstream file;
    char filename[20];
    char infile[20];
    int count=-1;
    for(;;)
    {
    cout<<"Enter the file name that you want to open or write 'quit' to exit: ";
    cin>>filename;
    if(filename == "quit")
        break;

    file.open(filename);
    assert(file);
    while(file)
    {
    file>>infile;
    cout<<infile<<" ";
    count++;
    }
    file.clear();
    file.close();
    cout<<endl<<"Words: "<<count<<endl;;
    count=-1;
    }


    system ("PAUSE");
}
if(filename == "quit")

use strcmp

Thanks that seems to have fixed it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.