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. 看错了。
|