CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2012
    Posts
    2

    Adding new string automatically

    Hi,

    Im sorry and im new here and haven't learned all the words around C++ programming so it was hard to search for a topic that had my answer :/

    But my question is:

    Im doing a little game, casting dices etc. The problem is that the program will ask for player 1 then if i enter a name and enter it will ask for player two and so going on until i just press enter with a empty field and then continue the game.

    The problem is i don't have any clue what code bits to start studying and how i shall lay it up, feels like i need a new string declaration automatically for each name.


    Thanks in forward

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

  3. #3
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: Adding new string automatically

    First of all you have to learn the very basics. Have you got a book or do you follow some online tutorial? If not get/find one, it will be overwhelming trying to grasp everything at once.
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

  4. #4
    Join Date
    Sep 2012
    Posts
    2

    Re: Adding new string automatically

    Hi S_M_A

    I'm sorry if i formulated me wrong but i know the really really basic i think

    But i received a tip above about vectors so i check that up

    But a friend told me to use an array?

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

    Re: Adding new string automatically

    Quote Originally Posted by Kungen View Post
    Hi S_M_A

    I'm sorry if i formulated me wrong but i know the really really basic i think

    But i received a tip above about vectors so i check that up

    But a friend told me to use an array?
    A vector is an array basically. It's just a lot more powerful than a simple array, but gives you the same functionality. A simple array requires you specify a size whereas a vector grows dynamically as needed, which seems more appropriate for your needs.

  6. #6
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: Adding new string automatically

    Your friend is probably using C most of the time so don't listen to him in this case. Listen to GCDEF instead and get used to using STL (browse around a bit at cplusplus.com to see what it offers). You might feel it's a lot of extra reading when all you want is to get down to business doing your game but in the end you will absolutely love it.
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

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