CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 3 of 3 FirstFirst 123
Results 31 to 33 of 33
  1. #31
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: A task involving linked lists and a headache

    Quote Originally Posted by MustSeeMelons
    rand()%4 would give me 0-4
    Actually, it will give you integers in the range [0, 3].
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  2. #32
    Join Date
    Sep 2012
    Posts
    11

    Re: A task involving linked lists and a headache

    I know, its 0<=x<4.

  3. #33
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: A task involving linked lists and a headache

    Quote Originally Posted by MustSeeMelons View Post
    Forgot to delete that pointer for the bunny, anyway, it wasnt used.
    Because, rand()%4 would give me 0-4, but those positions contain Male names, i need rand()%(14 - 10)+10 gives me 10-14, which are the names i need.
    Good grief.

    rand() % 4 + 10.

    The (14 - 10) just evaluates to 4. Why not just write 4? Why not (107 - 103)? Keep it as simple as possible.

Page 3 of 3 FirstFirst 123

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured