error: no matching function for call to 'std::basic_ifstream<char>::open(std::string&)
2016-05-20 20:37
751 查看
原文地址: http://blog.csdn.net/cs_zlg/article/details/8300124
[cpp] view
plain copy
print?
string filename = "1.txt";
ifstream fin;
fin.open(filename);
上述语句会产生如下错误:
error: no matching function for call to 'std::basic_ifstream<char>::open(std::string&)
原因是C++的string类无法作为open的参数。
解决方案:使用C的字符串。
例:
[cpp] view
plain copy
print?
char filename[10];
strcpy(filename, "1.txt");
ifstream fin;
fin.open(filename);
[cpp] view
plain copy
print?
string filename = "1.txt";
ifstream fin;
fin.open(filename);
上述语句会产生如下错误:
error: no matching function for call to 'std::basic_ifstream<char>::open(std::string&)
原因是C++的string类无法作为open的参数。
解决方案:使用C的字符串。
例:
[cpp] view
plain copy
print?
char filename[10];
strcpy(filename, "1.txt");
ifstream fin;
fin.open(filename);
相关文章推荐
- Linux 命令行模式快捷键使用
- Unable to import Tensorflow “No module named copyreg”
- CentOS(5.8/6.4)linux生产环境若干优化实战
- 坑爹的一天——关于配置samba服务器(1)
- Apache Cordova development lands on Visual Studio Code
- jetson tk1 上面如何编译opencv程序
- Apache Storm内部原理分析
- Linux源码环境下编译apk实践
- 从开始到结束,手把手教你使用busybox构建类嵌入式Linux系统
- Linux_2_Navigation
- Linux内核Makefile分析
- 执行shell脚本的几种方法及区别
- Linux文件权限
- launchOptions的key
- selinux禁用后系统无法正常启动的问题
- SHELL中计算时间差方法
- Linux的lvm管理:修改LV大小
- @安装Nginx创建错误
- 《Linux及安全》实践2
- Linux中常见find命令的使用