由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - What is wrong with the code?
相关主题
请问一个exception题目读取数据求教
C++ 初级再初级问题请问一个入门级 dynamic memory 的问题
菜鸟求教,一个c++的困惑C++ 在 windows 上 结果正确, 在 linux 上结果总是不一样,怎
a very simple c++ questionWhy no output file generate? What is wrong?
一个nested class的问题[合集] in visual studio, how to pass arguments into the progra
关于c++的constructor的面试题C++菜问: 怎么这样也可以?
c++ std::abs(int) ambiguous?奇怪的问题:关于一个简单的malloc()小程序 (转载)
腆着脸在问一道这个C++程序为什么不能运行
相关话题的讨论汇总
话题: argv话题: what话题: identical话题: c2话题: c1
进入Programming版参与讨论
1 (共1页)
c**********e
发帖数: 2007
1
This is a very simple code. When I use two identical files (copy to get
an identical copy), it always says "NOT identical".
What is wrong? Thanks a lot.
#include
#include
#include
#include
using namespace std;
int main(int argc, char *argv[])
{
ifstream fin1, fin2;
fin1.open(argv[0]);
fin2.open(argv[1]);
char c1, c2;
do {
fin1.get(c1);
fin2.get(c2);
if(c1!=c2) {
cout << "The two files are NOT identical." << endl;
t****t
发帖数: 6806
2
argv[1] and argv[2]....(not 0 and 1)

【在 c**********e 的大作中提到】
: This is a very simple code. When I use two identical files (copy to get
: an identical copy), it always says "NOT identical".
: What is wrong? Thanks a lot.
: #include
: #include
: #include
: #include
: using namespace std;
: int main(int argc, char *argv[])
: {

c*****t
发帖数: 1879
3
Two problems. thrust pointed out one

^^^^^^^^^^^^^^^^^^^^^
should be argv[1] and argv[2]
should be &c1 and &c2

【在 c**********e 的大作中提到】
: This is a very simple code. When I use two identical files (copy to get
: an identical copy), it always says "NOT identical".
: What is wrong? Thanks a lot.
: #include
: #include
: #include
: #include
: using namespace std;
: int main(int argc, char *argv[])
: {

t****t
发帖数: 6806
4
我发现你老了...istream::get(char& c)...

【在 c*****t 的大作中提到】
: Two problems. thrust pointed out one
:
: ^^^^^^^^^^^^^^^^^^^^^
: should be argv[1] and argv[2]
: should be &c1 and &c2

c*****t
发帖数: 1879
5
en. 看错了。

【在 t****t 的大作中提到】
: 我发现你老了...istream::get(char& c)...
d1
发帖数: 1213
6
you two are 2 style
u r c style
thrust is c++ style

en. 看错了。

【在 c*****t 的大作中提到】
: en. 看错了。
1 (共1页)
进入Programming版参与讨论
相关主题
这个C++程序为什么不能运行一个nested class的问题
char ** pt1和 char * pt2[] 的区别在哪?关于c++的constructor的面试题
A aimple C++ questionc++ std::abs(int) ambiguous?
为什么foo1可以而foo2不行?腆着脸在问一道
请问一个exception题目读取数据求教
C++ 初级再初级问题请问一个入门级 dynamic memory 的问题
菜鸟求教,一个c++的困惑C++ 在 windows 上 结果正确, 在 linux 上结果总是不一样,怎
a very simple c++ questionWhy no output file generate? What is wrong?
相关话题的讨论汇总
话题: argv话题: what话题: identical话题: c2话题: c1