| 
 | 
 
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册  
 
x
 
为什么这段代码没有输出? 
- #include <iostream>
 
 - #include <fstream>
 
 - #include <string>
 
  
- int main()
 
 - {
 
 -     std::ifstream fin("my.txt");
 
 -     if(!fin.is_open())
 
 -         std::cout << "open error";
 
 -         return 1;
 
 -     std::string temp;
 
 -     fin >> temp;
 
 -     fin.close();
 
 -     std::cout << '*' << temp << '*';
 
 - }
 
  复制代码 
my.txt 
- This is a test file.
 
 - You can write something anywhere.
 
 - It has 70 chars.
 
 - It has 4 lines.
 
  复制代码 
我粘贴了一下,然后代码就变成了这样 
- #include <iostream>
 
 - #include <fstream>
 
 - #include <string>
 
  
- int main()
 
 - {
 
 -     std::ifstream fin("my.txt");
 
 -     if(!fin.is_open())
 
 -         std::cout << "open error";
 
 -     return 1;
 
 -     std::string temp;
 
 -     fin >> temp;
 
 -     fin.close();
 
 -     std::cout << '*' << temp << '*';
 
 - }
 
 
  复制代码 
 
 
 |   
 
 
 
 |