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 :)
Re: Adding new string automatically
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.
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?
Re: Adding new string automatically
Quote:
Originally Posted by
Kungen
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.
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. :)