Problem with argv[]

I write in Linux in gedit, then execute program in terminal.
I have a problem with that program. Here is a code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <iostream>
#include <cstdio>

using namespace std;

int main(int argc, char* argv[])
{
    FILE *fp;
    char ch;
    
    if(argc!=2)
    {
        cout<<"You should enter a filename"<<endl;
        return 1;
    }
    if((fp=fopen(argv[1],"w"))==NULL)
    {
        cout<<"Can't open the file"<<endl;
        return 1;
    }
    do
    {
        ch=getchar();
        putc(ch,fp);
    }while(ch!="."); //mistake here but I don't know the way to correct it
    fclose(fp);

    return 0;
}


Compiler gives a mistake:
error: ISO C++ forbids comparison between pointer and integer
change }while(ch!="."); to }while(ch!='.');
You are trying to compare char with string literal.
You want char '.' not string "."

change

}while(ch!=".");

to

}while(ch!='.');
Thanks guys. I have done so stupid mistake.
Topic archived. No new replies allowed.