Word meaning

This is a discussion on Word meaning within the C Programming forums, part of the General Programming Boards category; What does this line translate into english. Its part of a do while loop.Ok let me rephrase the question how ...

  1. #1
    Registered User
    Join Date
    Oct 2012
    Posts
    14

    Word meaning

    What does this line translate into english. Its part of a do while loop.Ok let me rephrase the question how to write the stuff after while in such a way that the do loop keeps repeating if
    r1=0 and r2=0
    or
    r1=0 and r2=1
    or
    r1=1 and r2=0
    or
    (*hero)[r1][r2].gold=='G'
    Code:
    }while((r1==0 && r2==0)||(r1==0 && r2==1)||(r1==1 && r2==0)||((*hero)[r1][r2].gold=='G'));
    Last edited by Burns111; 11-28-2012 at 03:46 AM.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,941
    It looks like you succeeded in doing what you were asking about.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Nov 2012
    Posts
    1,197
    C:
    Code:
    }while((r1==0 && r2==0)||(r1==0 && r2==1)||(r1==1 && r2==0)||((*hero)[r1][r2].gold=='G'));

    English:
    repeat the above commands so long as either of the following conditions are true:
    1. (r1, r2) contain any of the following combinations:
    a. (0, 0)
    b. (0, 1)
    c. (1, 0)
    2. the 'gold' member of (*hero)[r1][r2] has the value 'G'

  4. #4
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    In number 1, you're omitting r0. What Burns11 posted the first time is correct.

  5. #5
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,941
    Eh, I think c99tutorial just quoted the code posted in post #1 verbatim. The thing is, that code appears to correspond exactly to the requirements, so I don't see a problem. All c99tutorial did was rephrase what it does, but there are so many different ways of rephrasing that so I'm not sure what's the point.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  6. #6
    Registered User
    Join Date
    Nov 2012
    Posts
    1,197
    Rephrasing could help to discover a clearer way to write something or find bugs. For example, in the context of the program, what is special about the combinations (0,0), (0,1) and (1,0)? If they are given special meaning and/or are used elsewhere in the program for some notion like "Heros in this team have deposited money in the bank" then it might help to document this somewhere or to give first-class status to such a notion with a separate function like hascredit(r1, r2).

  7. #7
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,941
    Quote Originally Posted by c99tutorial
    Rephrasing could help to discover a clearer way to write something or find bugs.
    Sure, if you are rephrasing to fit the context of the purpose of the code. In this case, there is no context, beyond the hint of "hero" and "gold".
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 13
    Last Post: 09-20-2012, 11:48 AM
  2. Replies: 28
    Last Post: 10-23-2011, 07:17 PM
  3. reading text-and-numbers file word by word
    By bored_guy in forum C Programming
    Replies: 22
    Last Post: 10-26-2009, 10:59 PM
  4. Dirty Word (Microsoft Word that is, you sicko!)
    By nickname_changed in forum A Brief History of Cprogramming.com
    Replies: 12
    Last Post: 07-02-2005, 07:27 AM
  5. open file, search of word, replace word with another
    By Unregistered in forum C++ Programming
    Replies: 0
    Last Post: 06-05-2002, 01:16 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21