#include<iostream>
#include<fstream>
using namespace std;
int main()
{
char x;
ifstream swp;
swp.open("swp.txt");
while (!swp.eof())
{
swp >> x;
}
cout << x;
swp.close();
return 0;
}

cout<<x写在循环里
你把cout写到了while循环的外面了
这导致你的这个char x,它会反复的被覆盖
如果你整个文档的最后一个字符是不可见的,比如空格或者换行,那可不啥也不显示吗