| |

VerySource

 Forgot password?
 Register
Search
Author: fordzyb

Read the file below, why is the running result 1 2 3 4 5 6 7 7 an additional 7

[Copy link]

0

Threads

55

Posts

44.00

Credits

Newbie

Rank: 1

Credits
44.00

 Invalid IP Address

Post time: 2020-6-4 00:00:01
| Show all posts
while (fin.read((char *)&x,4))
{
cout << x<< "";
}
Reply

Use magic Report

0

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-6-5 20:30:01
| Show all posts
Change the following to
do {
fin.read((char *)&x,4);
cout << x<< "";
} while (!fin.eof());
》》
while (fin.read((char *)&x,4))
{
     cout << x<< "";
}
There is no problem
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list