s*****n 发帖数: 1279 | 1 Both try1.cpp and try2.cpp can be complied, but only try1.cpp works. when I
run try2.cpp, I always got "Segmentation fault". So what is wrong with try2
.cpp? why I can't use ifstream pointer? Thank you!
try1.cpp
#include
#include
#include
using namespace std;
int main()
{
ifstream gains("coeff.txt");
if (!gains.is_open())
{
cout<<"coeff.txt could not be opened! " <
}
else{
cout<<"coeff.txt is open"<
}
return | t****t 发帖数: 6806 | 2 你分配了指针,没分配对象
I
try2
【在 s*****n 的大作中提到】 : Both try1.cpp and try2.cpp can be complied, but only try1.cpp works. when I : run try2.cpp, I always got "Segmentation fault". So what is wrong with try2 : .cpp? why I can't use ifstream pointer? Thank you! : try1.cpp : #include : #include : #include : using namespace std; : int main() : {
| s*****n 发帖数: 1279 | 3 Yes, thank you very much!
That's really a stupid mistake.
【在 t****t 的大作中提到】 : 你分配了指针,没分配对象 : : I : try2
|
|