TalkChess.com
Hosted by Your Move Chess & Games

Author Message
Ronald de Man

Joined: 28 Feb 2012
Posts: 4075

Post subject: Re: I'm not very happy with the do {} while() statement in C    Posted: Sun Feb 18, 2018 9:51 am

If you want to break in the middle of the loop, then use break:
 Code: k = i + dir[j];         if (initBoard[k])  {           y = k / 10; x = k - y * 10 - 1; y -= 2;           ts = y * 8 + x;           dirKi[sq] |= (u64)1 << ts;           while (1) {             dirPtr[j][sq] |= ((u64)1 << ts);             k += dir[j];             if (!initBoard[k])               break;             y = k / 10; x = k - y * 10 - 1; y -= 2;             ts = y * 8 + x;           }         }

Or use a for statement:
 Code: k = i + dir[j];         if (initBoard[k])  {           y = k / 10; x = k - y * 10 - 1; y -= 2;           ts = y * 8 + x;           dirKi[sq] |= (u64)1 << ts;           for (;             dirPtr[j][sq] |= ((u64)1 << ts),             k += dir[j],             initBoard[k];             y = k / 10, x = k - y * 10 - 1, y -= 2,             ts = y * 8 + x           );         }

_________________
https://github.com/syzygy1/tb
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First
Subject Author Date/Time
Michael Sherwin Sun Feb 18, 2018 8:06 am
Marco Belli Sun Feb 18, 2018 8:47 am
Michael Sherwin Sun Feb 18, 2018 9:03 am
Nguyen Pham Sun Feb 18, 2018 9:11 am
Michael Sherwin Sun Feb 18, 2018 9:21 am
Nguyen Pham Sun Feb 18, 2018 9:42 am
Re: I'm not very happy with the do {} while() statement in C Ronald de Man Sun Feb 18, 2018 9:51 am
Michael Sherwin Sun Feb 18, 2018 10:07 am
Ronald de Man Sun Feb 18, 2018 10:21 am
Michael Sherwin Sun Feb 18, 2018 10:23 am
Rasmus Althoff Sun Feb 18, 2018 9:42 am
Michael Sherwin Sun Feb 18, 2018 10:05 am
Rasmus Althoff Sun Feb 18, 2018 10:27 am
Michael Sherwin Sun Feb 18, 2018 10:34 am
Michael Sherwin Sun Feb 18, 2018 10:54 am
Rasmus Althoff Sun Feb 18, 2018 11:00 am
Michael Sherwin Sun Feb 18, 2018 11:09 am
Rasmus Althoff Sun Feb 18, 2018 11:20 am
Michael Sherwin Sun Feb 18, 2018 11:48 am
Rasmus Althoff Sun Feb 18, 2018 12:40 pm
Michael Sherwin Sun Feb 18, 2018 1:56 pm
Ronald de Man Sun Feb 18, 2018 2:34 pm
Sven Schüle Tue Feb 20, 2018 12:23 am
Michael Sherwin Tue Feb 20, 2018 2:25 am
Michael Sherwin Tue Feb 20, 2018 5:39 am
Sven Schüle Tue Feb 20, 2018 10:37 pm
Michael Sherwin Tue Feb 20, 2018 11:59 pm
Fulvio Benini Wed Feb 21, 2018 10:08 am
Michael Sherwin Mon Mar 05, 2018 12:03 am
Álvaro Begué Mon Mar 05, 2018 1:03 am
Michael Sherwin Mon Mar 05, 2018 1:11 am
Álvaro Begué Mon Mar 05, 2018 1:27 am
Michael Sherwin Mon Mar 05, 2018 2:09 am
Lucas Braesch Wed Mar 07, 2018 4:06 am
Michael Sherwin Wed Mar 07, 2018 12:54 pm
Lucas Braesch Wed Mar 07, 2018 11:29 pm
Marco Costalba Fri Mar 09, 2018 8:40 am
Michael Sherwin Fri Mar 09, 2018 3:35 pm
Alcides Schulz Wed Mar 07, 2018 11:32 pm
Ed Schroder Fri Mar 09, 2018 2:59 pm
Michael Sherwin Fri Mar 09, 2018 3:25 pm
Rasmus Althoff Fri Mar 09, 2018 3:47 pm
Richard Delorme Fri Mar 09, 2018 7:07 pm
Michael Sherwin Fri Mar 09, 2018 7:43 pm
Rasmus Althoff Fri Mar 09, 2018 8:11 pm
Rasmus Althoff Sat Mar 10, 2018 9:58 am
Rasmus Althoff Fri Mar 09, 2018 8:14 pm
Robert Hyatt Sat Mar 10, 2018 4:20 am
Martin Sedlak Sat Mar 10, 2018 9:21 am
Martin Sedlak Sat Mar 10, 2018 9:29 am
Robert Hyatt Sat Mar 10, 2018 6:08 pm
Martin Sedlak Sat Mar 10, 2018 6:37 pm
Robert Hyatt Sat Mar 10, 2018 10:13 pm
Martin Sedlak Sat Mar 10, 2018 10:45 pm
Robert Hyatt Wed Mar 14, 2018 2:06 am
Rasmus Althoff Fri Mar 23, 2018 3:33 pm
Martin Sedlak Fri Mar 23, 2018 7:19 pm
Álvaro Begué Fri Mar 23, 2018 7:29 pm
Ronald de Man Fri Mar 23, 2018 8:51 pm
Ronald de Man Fri Mar 23, 2018 8:55 pm
Álvaro Begué Sat Mar 24, 2018 12:00 am
Robert Hyatt Fri Mar 23, 2018 4:17 am
Martin Sedlak Fri Mar 23, 2018 7:33 pm
Rasmus Althoff Sat Mar 10, 2018 7:16 pm
Matthew Hull Sat Mar 10, 2018 9:17 pm
Robert Hyatt Sat Mar 10, 2018 10:18 pm
Rasmus Althoff Sat Mar 10, 2018 10:40 pm
Rasmus Althoff Sat Mar 10, 2018 10:54 pm
Matthew Hull Sun Mar 11, 2018 11:14 am
Rasmus Althoff Sun Mar 11, 2018 1:51 pm
Ronald de Man Sun Mar 11, 2018 12:32 pm
Rasmus Althoff Sun Mar 11, 2018 1:42 pm
Robert Hyatt Wed Mar 14, 2018 2:20 am
laurie tunnicliffe Sun Mar 11, 2018 9:16 am
Lucas Braesch Sun Mar 11, 2018 11:11 am
Ed Schroder Sat Mar 10, 2018 9:59 am
P. Kumar Mon Mar 05, 2018 4:42 am
Martin Sedlak Sun Feb 18, 2018 5:39 pm
Michael Sherwin Sun Feb 18, 2018 5:59 pm
Martin Sedlak Sun Feb 18, 2018 6:40 pm
Michael Sherwin Sun Feb 18, 2018 7:16 pm
Ronald de Man Sun Feb 18, 2018 8:39 pm
Rasmus Althoff Sun Feb 18, 2018 10:06 pm
Martin Sedlak Sun Feb 18, 2018 10:32 pm
Ronald de Man Sun Feb 18, 2018 11:53 pm
Rasmus Althoff Mon Feb 19, 2018 5:58 pm
Martin Sedlak Sun Feb 18, 2018 9:33 pm
Rasmus Althoff Sun Feb 18, 2018 7:04 pm
Ronald de Man Sun Feb 18, 2018 9:12 pm
Rasmus Althoff Sun Feb 18, 2018 10:05 pm
Robert Hyatt Tue Feb 20, 2018 5:22 am
Michael Sherwin Tue Feb 20, 2018 6:14 am
Michael Sherwin Tue Feb 20, 2018 6:33 am
Robert Hyatt Tue Feb 20, 2018 10:23 pm
Michael Sherwin Tue Feb 20, 2018 11:52 pm
Álvaro Begué Tue Feb 20, 2018 11:45 pm
Michael Sherwin Wed Feb 21, 2018 12:15 am
H.G.Muller Wed Feb 21, 2018 8:34 am
Robert Hyatt Thu Feb 22, 2018 2:21 am
Ronald de Man Thu Feb 22, 2018 12:51 pm
Robert Hyatt Fri Feb 23, 2018 4:12 am
Rasmus Althoff Thu Feb 22, 2018 5:58 pm
Eugene Kotlov Thu Feb 22, 2018 6:16 pm
Rasmus Althoff Thu Feb 22, 2018 5:54 pm
Robert Hyatt Fri Feb 23, 2018 4:22 am
Lucas Braesch Mon Feb 19, 2018 11:45 am
Michael Sherwin Mon Feb 19, 2018 2:13 pm
Robert Hyatt Tue Feb 20, 2018 5:13 am
laurie tunnicliffe Mon Mar 05, 2018 12:22 am
Michael Sherwin Mon Mar 05, 2018 1:04 am
Álvaro Begué Mon Mar 05, 2018 1:06 am
Rasmus Althoff Wed Mar 07, 2018 4:58 pm

 Jump to: Select a forum Computer Chess Club Forums----------------Computer Chess Club: General TopicsComputer Chess Club: Tournaments and MatchesComputer Chess Club: Programming and Technical DiscussionsComputer Chess Club: Engine Origins Other Forums----------------Chess Thinkers ForumChess Players ForumForum Help and Suggestions
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum