-
September 17th, 2012, 03:00 PM
#1
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
-
September 18th, 2012, 10:40 AM
#2
Re: Adding new string automatically
-
September 18th, 2012, 10:58 AM
#3
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.
-
September 18th, 2012, 01:43 PM
#4
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?
-
September 18th, 2012, 02:29 PM
#5
Re: Adding new string automatically
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.
-
September 18th, 2012, 03:18 PM
#6
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|