请问,为什么程序可以运行,文本也可以建立但是却无法输入内容?

#include
#include

using namespace std;

int main() {

ifstream d;     
char a[100];        
d.open("TEST.txt", ios::in);        

if (!d) {   

    cout << "Can't open file." << endl;

}


else {

    d.getline(a, 100);

    cout << a << endl;

    d.close();


}

int main(int argc, char* argv[]);
{
    ifstream d("TEST.txt");
    if (!d)
    {
        cout << "Can't open file." << endl;
    }

    char ch = 0;
    while (d.getline(a,100))
    {
        if (ch >= 'a' && ch <= 'z')
        {
            ch -= 32;
        }
        else if (ch >= 'A' && ch <= 'Z')
        {
            ch += 32;
        }
        ofstream out("TEST1.txt");
        if (!out)
        {
            return false;
        }
        else {

            out << ch << endl;
        }
        out.close();
    }
    d.close();
    return 0;
}

}

用ofstream时,每当你打开一个要放你输出的文件,C++会将其的所有内容清空。而你在循环中不停地打开再关闭,每次都会清空。
况且,你的ch我感觉有问题,初值不对吧。像你这么写ch就一直是0了,当然不会有输出了。运行根本就不会进入if,也就不可能改变ch的值了。