My program in C++ doesn't stop on if(scanf()==EOF)break;, below is sketch of my program, for example input:
X XjhgXjhX
gives output:
jhgjh
that is - it prints all characters except X, but it doesn't stop on Ctrl+Z.
using namespace std;
int main()
{
    char str[100]={0},znak,forbd;
    int i=0,j=0;
    while(true)
    {
        i=0;
        j=0;
        if(scanf("%c",&forbd)==EOF)
            break;
        if(scanf("%c",&znak)==EOF)
            break;
        while(znak!='\n')
        {
            if(forbd!=znak && znak!=' ')
            {
                str[i]=znak;
                i++;
                //cout<<i<<"\n";
            }
            if(scanf("%c",&znak)==EOF)
                break;
        }
        while(j<i)
        {
            printf("%c",str[j]);
            j++;
        }
        printf("%c",'\n');
    }
    return 0;   
}
I don't want to use cin, because of trouble with reading \n.
 
     
    