由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - a very simple c++ question
相关主题
What is wrong with the code?fstream不能做类的成员吗
读取数据求教C++ problem
关于文件读取的C++ 问题?关于c++的constructor的面试题
fstream 扫盲,谢谢!谁给说说bitwise operation
问一个C++文件读取的问题一个关于assignment constructor和expection的问题
how to read a sentence into a vector of string?purify和valgrind的比较
请问一个入门级 dynamic memory 的问题some c++ question.
C++ Q 99-102 (转载)c++ std::abs(int) ambiguous?
相关话题的讨论汇总
话题: ifstream话题: include话题: endl话题: cout话题: try2
进入Programming版参与讨论
1 (共1页)
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

1 (共1页)
进入Programming版参与讨论
相关主题
c++ std::abs(int) ambiguous?问一个C++文件读取的问题
腆着脸在问一道how to read a sentence into a vector of string?
一个nested class的问题请问一个入门级 dynamic memory 的问题
关于C++中 extern "C"的问题。C++ Q 99-102 (转载)
What is wrong with the code?fstream不能做类的成员吗
读取数据求教C++ problem
关于文件读取的C++ 问题?关于c++的constructor的面试题
fstream 扫盲,谢谢!谁给说说bitwise operation
相关话题的讨论汇总
话题: ifstream话题: include话题: endl话题: cout话题: try2