| |

VerySource

 Forgot password?
 Register
Search
Author: 8919795

Is there a general way to change GOTO into a loop? What should I do?

[Copy link]

0

Threads

8

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-6-14 11:31:42
| Show all posts
My WeChat zhu299, free to learn
Reply

Use magic Report

0

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-6-21 20:45:01
| Show all posts
do
{
    if (...)
    {
        break;
    }

    if (...)
    {
        break;
    }

    ....

    if (...)
    {
        break;
    }

    End processing
    return success
}
while(false);

Error handling
return failed
Reply

Use magic Report

0

Threads

24

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-6-30 16:00:02
| Show all posts
Can be changed to
do{
}
while(loop);
Reply

Use magic Report

0

Threads

23

Posts

13.00

Credits

Newbie

Rank: 1

Credits
13.00

 China

Post time: 2020-7-2 10:15:01
| Show all posts
Change goto to return.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-7-16 18:15:01
| Show all posts
Change GOTO to cycle? ?
It seems that the loop can be changed to GOTO;
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-7-17 15:00:01
| Show all posts
Depending on the specific problem, there is no general method.
  However, using goto is not a big deal...especially when jumping out of a deep and deep loop, I have not found a simpler method than goto.
Reply

Use magic Report

0

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 France

Post time: 2020-7-18 20:30:02
| Show all posts
Goto is a weapon.
Reply

Use magic Report

0

Threads

8

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-7-30 22:30:01
| Show all posts
Some goto cannot be changed into a loop
Some hardly changed things are messy after the change

goto is a good stuff~~~ I like it! !
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-7-31 20:00:01
| Show all posts
do
{
}while(0)
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-2 14:45:01
| Show all posts
Goto must be changed to while, this is proven.

However, I don't know how to do it in the actual methodology.I am also having a headache on this issue recently. I hope everyone can provide some ideas.
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